@thunderid/vue 0.0.5 → 0.2.0

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ApplicationNativeAuthenticationConstants, DEFAULT_THEME, EmbeddedFlowActionVariantV2 as EmbeddedFlowActionVariant, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowComponentTypeV2, EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType, EmbeddedFlowEventTypeV2, EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowStatus, EmbeddedFlowTextVariantV2 as EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowAuthenticatorKnownIdPType, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatus, EmbeddedSignInFlowStepType, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowTypeV2 as EmbeddedSignInFlowType, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, Platform, ThunderIDAPIError, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, TranslationBundleConstants, WellKnownSchemaIds, arrayBufferToBase64url, base64urlToArrayBuffer, createClassObserver, createClassObserver as createClassObserver$1, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createPackageComponentLogger, createPackageLogger, createTheme, deepMerge, deriveOrganizationHandleFromBaseUrl, detectThemeMode, detectThemeMode as detectThemeMode$1, executeEmbeddedSignInFlowV2, executeEmbeddedSignUpFlowV2, extractEmojiFromUri, extractUserClaimsFromIdToken, flattenUserSchema, generateFlattenedUserProfile, generateUserProfile, get, getActiveTheme, getAllOrganizations, getDefaultI18nBundles, getFlowMetaV2, getMeOrganizations, getSchemas, getScim2Me, handleWebAuthnAuthentication, handleWebAuthnAuthentication as handleWebAuthnAuthentication$1, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, http, isEmojiUri, isEmpty, navigate, navigate as navigate$1, normalizeTranslations, resolveFlowTemplateLiterals, transformBrandingPreferenceToTheme, updateMeProfile, withVendorCSSClassPrefix } from "@thunderid/browser";
1
+ import { ApplicationNativeAuthenticationConstants, DEFAULT_THEME, EmbeddedFlowActionVariantV2 as EmbeddedFlowActionVariant, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowComponentTypeV2, EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType, EmbeddedFlowEventTypeV2, EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowStatus, EmbeddedFlowTextVariantV2 as EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowAuthenticatorKnownIdPType, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatus, EmbeddedSignInFlowStepType, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowTypeV2 as EmbeddedSignInFlowType, EmbeddedSignUpFlowStatusV2, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, Platform, ThunderIDAPIError, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, TranslationBundleConstants, WellKnownSchemaIds, arrayBufferToBase64url, base64urlToArrayBuffer, createClassObserver, createClassObserver as createClassObserver$1, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createPackageComponentLogger, createPackageLogger, createTheme, deepMerge, deriveOrganizationHandleFromBaseUrl, detectThemeMode, detectThemeMode as detectThemeMode$1, executeEmbeddedSignInFlowV2, executeEmbeddedSignUpFlowV2, extractEmojiFromUri, extractUserClaimsFromIdToken, flattenUserSchema, generateFlattenedUserProfile, generateUserProfile, get, getActiveTheme, getAllOrganizations, getDefaultI18nBundles, getFlowMetaV2, getMeOrganizations, getSchemas, getScim2Me, handleWebAuthnAuthentication, handleWebAuthnAuthentication as handleWebAuthnAuthentication$1, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, http, isEmojiUri, isEmpty, navigate, navigate as navigate$1, normalizeTranslations, resolveFlowTemplateLiterals, transformBrandingPreferenceToTheme, updateMeProfile, withVendorCSSClassPrefix } from "@thunderid/browser";
2
2
  import { Fragment, computed, defineComponent, h, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, readonly, ref, shallowReadonly, shallowRef, watch } from "vue";
3
3
  import DOMPurify from "dompurify";
4
4
 
@@ -140,8 +140,10 @@ const FlowMetaProvider = defineComponent({
140
140
  try {
141
141
  meta.value = await getFlowMetaV2({
142
142
  baseUrl,
143
- id: applicationId,
144
- type: FlowMetaType.App
143
+ ...applicationId ? {
144
+ id: applicationId,
145
+ type: FlowMetaType.App
146
+ } : {}
145
147
  });
146
148
  } catch (err) {
147
149
  error.value = err instanceof Error ? err : new Error(String(err));
@@ -156,9 +158,11 @@ const FlowMetaProvider = defineComponent({
156
158
  try {
157
159
  const result = await getFlowMetaV2({
158
160
  baseUrl,
159
- id: applicationId,
160
- language,
161
- type: FlowMetaType.App
161
+ ...applicationId ? {
162
+ id: applicationId,
163
+ type: FlowMetaType.App
164
+ } : {},
165
+ language
162
166
  });
163
167
  if (result.i18n?.translations && i18nContext?.injectBundles) {
164
168
  const flatTranslations = {};
@@ -920,7 +924,7 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
920
924
  async getUser(options) {
921
925
  try {
922
926
  let baseUrl = options?.baseUrl;
923
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
927
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
924
928
  return generateUserProfile(await getScim2Me_default({ baseUrl }), flattenUserSchema(await getSchemas_default({ baseUrl })));
925
929
  } catch (error) {
926
930
  return extractUserClaimsFromIdToken(await this.getDecodedIdToken());
@@ -936,7 +940,7 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
936
940
  return this.withLoading(async () => {
937
941
  try {
938
942
  let baseUrl = options?.baseUrl;
939
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
943
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
940
944
  const profile = await getScim2Me_default({
941
945
  baseUrl,
942
946
  instanceId: this.getInstanceId()
@@ -962,7 +966,7 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
962
966
  async getMyOrganizations(options) {
963
967
  try {
964
968
  let baseUrl = options?.baseUrl;
965
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
969
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
966
970
  return await getMeOrganizations_default({
967
971
  baseUrl,
968
972
  instanceId: this.getInstanceId()
@@ -974,7 +978,7 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
974
978
  async getAllOrganizations(options) {
975
979
  try {
976
980
  let baseUrl = options?.baseUrl;
977
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
981
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
978
982
  return await getAllOrganizations_default({
979
983
  baseUrl,
980
984
  instanceId: this.getInstanceId()
@@ -988,9 +992,9 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
988
992
  return await this.withLoading(async () => {
989
993
  const idToken = await this.getDecodedIdToken();
990
994
  return {
991
- id: idToken?.org_id,
992
- name: idToken?.org_name,
993
- orgHandle: idToken?.org_handle
995
+ id: idToken?.org_id ?? "",
996
+ name: idToken?.org_name ?? "",
997
+ orgHandle: idToken?.org_handle ?? ""
994
998
  };
995
999
  });
996
1000
  } catch (error) {
@@ -1000,7 +1004,7 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
1000
1004
  async switchOrganization(organization) {
1001
1005
  return this.withLoading(async () => {
1002
1006
  try {
1003
- const sourceInstanceId = this.getStorageManager().getConfigData()?.organizationChain?.sourceInstanceId;
1007
+ const sourceInstanceId = (await this.getStorageManager().getConfigData())?.organizationChain?.sourceInstanceId;
1004
1008
  if (!organization.id) throw new ThunderIDRuntimeError$1("Organization ID is required for switching organizations", "vue-ThunderIDVueClient-SwitchOrganizationError-001", "vue", "The organization object must contain a valid ID to perform the organization switch.");
1005
1009
  const exchangeConfig = {
1006
1010
  attachToken: false,
@@ -1039,14 +1043,12 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
1039
1043
  const arg2 = args[1];
1040
1044
  if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
1041
1045
  if (typeof arg1 === "object" && arg1 !== null && !isEmpty(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
1042
- const configData = this.getStorageManager().getConfigData();
1046
+ const configData = await this.getStorageManager().getConfigData();
1043
1047
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
1044
- const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
1045
- const authId = authIdFromUrl || authIdFromStorage;
1046
- const baseUrlFromStorage = sessionStorage.getItem("thunderid_base_url");
1048
+ const authIdFromStorage = await this.getStorageManager().getHybridDataParameter("authId");
1047
1049
  const response = await executeEmbeddedSignInFlowV2({
1048
- authId,
1049
- baseUrl: configData?.baseUrl || baseUrlFromStorage,
1050
+ authId: authIdFromUrl || authIdFromStorage || "",
1051
+ baseUrl: configData?.baseUrl || "",
1050
1052
  payload: arg1,
1051
1053
  url: arg2?.url
1052
1054
  });
@@ -1073,14 +1075,14 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
1073
1075
  return await super.signInSilently(options);
1074
1076
  }
1075
1077
  async signUp(...args) {
1076
- const configData = this.getStorageManager().getConfigData();
1078
+ const configData = await this.getStorageManager().getConfigData();
1077
1079
  const firstArg = args[0];
1078
- const baseUrl = configData?.baseUrl;
1080
+ const baseUrl = configData?.baseUrl || "";
1079
1081
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
1080
- const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
1081
- const authId = authIdFromUrl || authIdFromStorage;
1082
- if (authIdFromUrl && !authIdFromStorage) sessionStorage.setItem("thunderid_auth_id", authIdFromUrl);
1083
- return executeEmbeddedSignUpFlowV2({
1082
+ const authIdFromStorage = await this.getStorageManager().getHybridDataParameter("authId");
1083
+ const authId = authIdFromUrl || authIdFromStorage || "";
1084
+ if (authIdFromUrl && !authIdFromStorage) await this.getStorageManager().setHybridDataParameter("authId", authIdFromUrl);
1085
+ const response = await executeEmbeddedSignUpFlowV2({
1084
1086
  authId,
1085
1087
  baseUrl,
1086
1088
  payload: typeof firstArg === "object" && "flowType" in firstArg ? {
@@ -1088,12 +1090,27 @@ var ThunderIDVueClient = class extends ThunderIDBrowserClient {
1088
1090
  verbose: true
1089
1091
  } : firstArg
1090
1092
  });
1093
+ if (response && typeof response === "object" && response.flowStatus === EmbeddedSignUpFlowStatusV2.Complete && response.assertion) {
1094
+ const decodedAssertion = await this.decodeJwtToken(response.assertion);
1095
+ const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
1096
+ const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
1097
+ await this.setSession({
1098
+ access_token: response.assertion,
1099
+ created_at: createdAt,
1100
+ expires_in: expiresIn,
1101
+ id_token: response.assertion,
1102
+ scope: decodedAssertion.scope,
1103
+ token_type: "Bearer"
1104
+ });
1105
+ this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion));
1106
+ }
1107
+ return response;
1091
1108
  }
1092
1109
  async request(requestConfig) {
1093
- return this.httpRequest(requestConfig);
1110
+ return await this.httpRequest(requestConfig);
1094
1111
  }
1095
1112
  async requestAll(requestConfigs) {
1096
- return this.httpRequestAll(requestConfigs);
1113
+ return await this.httpRequestAll(requestConfigs);
1097
1114
  }
1098
1115
  async getAccessToken(sessionId) {
1099
1116
  return super.getAccessToken(sessionId);
@@ -1177,7 +1194,7 @@ const ThunderIDProvider = defineComponent({
1177
1194
  },
1178
1195
  scopes: {
1179
1196
  default: void 0,
1180
- type: Array
1197
+ type: [Array, String]
1181
1198
  },
1182
1199
  signInOptions: {
1183
1200
  default: void 0,
@@ -1215,8 +1232,8 @@ const ThunderIDProvider = defineComponent({
1215
1232
  let loadingCheckInterval;
1216
1233
  function buildConfig() {
1217
1234
  return {
1218
- afterSignInUrl: props.afterSignInUrl,
1219
- afterSignOutUrl: props.afterSignOutUrl,
1235
+ afterSignInUrl: props.afterSignInUrl ?? window.location.origin,
1236
+ afterSignOutUrl: props.afterSignOutUrl ?? window.location.origin,
1220
1237
  applicationId: props.applicationId,
1221
1238
  baseUrl: props.baseUrl,
1222
1239
  clientId: props.clientId,
@@ -1311,10 +1328,12 @@ const ThunderIDProvider = defineComponent({
1311
1328
  await client.clearSession(...args);
1312
1329
  },
1313
1330
  clientId: props.clientId,
1331
+ scopes: props.scopes,
1314
1332
  exchangeToken: (config) => client.exchangeToken(config),
1315
1333
  getAccessToken: () => client.getAccessToken(),
1316
1334
  getDecodedIdToken: () => client.getDecodedIdToken(),
1317
1335
  getIdToken: () => client.getIdToken(),
1336
+ getStorageManager: () => client.getStorageManager(),
1318
1337
  http: {
1319
1338
  request: (requestConfig) => client.request(requestConfig),
1320
1339
  requestAll: (requestConfigs) => client.requestAll(requestConfigs)
@@ -1344,7 +1363,8 @@ const ThunderIDProvider = defineComponent({
1344
1363
  onMounted(async () => {
1345
1364
  const config = buildConfig();
1346
1365
  await client.initialize(config);
1347
- const initializedConfig = client.getConfiguration();
1366
+ await client.getDiscoveryResponse();
1367
+ const initializedConfig = await client.getConfiguration();
1348
1368
  if (initializedConfig?.baseUrl) sessionStorage.setItem("thunderid_base_url", initializedConfig.baseUrl);
1349
1369
  try {
1350
1370
  isInitialized.value = await client.isInitialized();
@@ -1397,7 +1417,7 @@ const ThunderIDProvider = defineComponent({
1397
1417
  onUpdateProfile: (updatedUser) => {
1398
1418
  user.value = updatedUser;
1399
1419
  userProfile.value = {
1400
- flattenedProfile: generateFlattenedUserProfile(updatedUser, userProfile.value?.schemas),
1420
+ flattenedProfile: generateFlattenedUserProfile(updatedUser, userProfile.value?.schemas ?? []),
1401
1421
  profile: updatedUser,
1402
1422
  schemas: userProfile.value?.schemas ?? []
1403
1423
  };
@@ -7342,7 +7362,7 @@ const BaseSignIn$2 = defineComponent({
7342
7362
  onSubmit: (e) => {
7343
7363
  e.preventDefault();
7344
7364
  const fd = {};
7345
- currentAuthenticator.value.metadata?.params?.forEach((p) => {
7365
+ currentAuthenticator.value?.metadata?.params?.forEach((p) => {
7346
7366
  fd[p.param] = formValues.value[p.param] || "";
7347
7367
  });
7348
7368
  handleSubmit(fd);
@@ -7499,7 +7519,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7499
7519
  case EmbeddedFlowComponentTypeV2.TextInput:
7500
7520
  case EmbeddedFlowComponentTypeV2.PasswordInput:
7501
7521
  case EmbeddedFlowComponentTypeV2.EmailInput: {
7502
- const identifier = component.ref;
7522
+ const identifier = component.ref ?? "";
7503
7523
  const value = formValues[identifier] || "";
7504
7524
  const error = touchedFields[identifier] || false ? formErrors[identifier] : void 0;
7505
7525
  const fieldType = getFieldType(component.type);
@@ -7533,14 +7553,14 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7533
7553
  const isDeny = componentVariant.toLowerCase() !== "primary";
7534
7554
  const decisions = { purposes: consentPrompt.purposes.map((p) => ({
7535
7555
  approved: !isDeny,
7536
- elements: [...p.essential.map((attr) => ({
7556
+ elements: [...p.essential.map((e) => ({
7537
7557
  approved: !isDeny,
7538
- name: attr
7539
- })), ...p.optional.map((attr) => ({
7540
- approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, attr)] !== "false",
7541
- name: attr
7558
+ name: e.name
7559
+ })), ...p.optional.map((e) => ({
7560
+ approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, e.name)] !== "false",
7561
+ name: e.name
7542
7562
  }))],
7543
- purposeName: p.purposeName
7563
+ purposeName: p.purposeName ?? ""
7544
7564
  })) };
7545
7565
  formData["consent_decisions"] = JSON.stringify(decisions);
7546
7566
  }
@@ -7601,7 +7621,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7601
7621
  }, { default: () => buttonText || "Submit" });
7602
7622
  }
7603
7623
  case EmbeddedFlowComponentTypeV2.Text: {
7604
- const variant = getTypographyVariant(component.variant);
7624
+ const variant = getTypographyVariant(component.variant ?? "");
7605
7625
  return h(Typography_default, {
7606
7626
  key,
7607
7627
  style: {
@@ -7616,7 +7636,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7616
7636
  return h(Divider_default, { key }, dividerLabel ? { default: () => dividerLabel } : void 0);
7617
7637
  }
7618
7638
  case EmbeddedFlowComponentTypeV2.Select: {
7619
- const identifier = component.ref;
7639
+ const identifier = component.ref ?? "";
7620
7640
  const value = formValues[identifier] || "";
7621
7641
  const error = touchedFields[identifier] || false ? formErrors[identifier] : void 0;
7622
7642
  const selectOptions = (component.options || []).map((opt) => ({
@@ -7718,7 +7738,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7718
7738
  const renderSignInComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7719
7739
  ...options,
7720
7740
  key: component.id || index
7721
- })).filter(Boolean);
7741
+ })).filter((v) => v !== null);
7722
7742
  /**
7723
7743
  * Processes an array of components and renders them as VNodes for sign-up.
7724
7744
  * Identical to renderSignInComponents — separated for semantic clarity.
@@ -7726,7 +7746,7 @@ const renderSignInComponents = (components, formValues, touchedFields, formError
7726
7746
  const renderSignUpComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7727
7747
  ...options,
7728
7748
  key: component.id || index
7729
- })).filter(Boolean);
7749
+ })).filter((v) => v !== null);
7730
7750
  /**
7731
7751
  * Processes an array of components and renders them as VNodes for invite-user flows.
7732
7752
  * Identical to renderSignInComponents — separated for semantic clarity.
@@ -7734,7 +7754,7 @@ const renderSignUpComponents = (components, formValues, touchedFields, formError
7734
7754
  const renderInviteUserComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7735
7755
  ...options,
7736
7756
  key: component.id || index
7737
- })).filter(Boolean);
7757
+ })).filter((v) => v !== null);
7738
7758
 
7739
7759
  //#endregion
7740
7760
  //#region src/utils/v2/resolveTranslationsInObject.ts
@@ -7840,10 +7860,26 @@ const transformComponents = (response, t, resolveTranslations = true, meta) => {
7840
7860
  };
7841
7861
  /**
7842
7862
  * Extract error message from flow error response.
7843
- * Supports any flow error response that follows the standard structure.
7844
- * Prioritizes failureReason if present, otherwise falls back to translated generic message.
7863
+ *
7864
+ * Resolution order:
7865
+ * 1. Structured `error` object: try i18n lookup via `t(error.message.key)`.
7866
+ * 2. Fallback to `defaultValue` from `message`, then `description`.
7867
+ * 3. Standard `Error.message`.
7868
+ * 4. Generic translated fallback via `defaultErrorKey`.
7845
7869
  */
7846
7870
  const extractErrorMessage = (error, t, defaultErrorKey = "errors.flow.generic") => {
7871
+ if (error && typeof error === "object" && error.error) {
7872
+ const flowError = error.error;
7873
+ if (flowError?.message?.key) {
7874
+ const translated = t(flowError.message.key);
7875
+ if (translated && translated !== flowError.message.key) return translated;
7876
+ const systemKey = `system.${flowError.message.key}`;
7877
+ const systemTranslated = t(systemKey);
7878
+ if (systemTranslated && systemTranslated !== systemKey) return systemTranslated;
7879
+ }
7880
+ const fallback = flowError?.message?.defaultValue ?? flowError?.description?.defaultValue;
7881
+ if (fallback) return fallback;
7882
+ }
7847
7883
  if (error && typeof error === "object" && error.failureReason) return error.failureReason;
7848
7884
  if (error instanceof Error && error.message) return error.message;
7849
7885
  return t(defaultErrorKey);
@@ -7998,7 +8034,7 @@ const BaseSignIn$1 = defineComponent({
7998
8034
  });
7999
8035
  const isFormValid = computed(() => Object.keys(formErrors.value).length === 0);
8000
8036
  const handleError = (error) => {
8001
- const errorMessage = error?.failureReason || extractErrorMessage(error, t);
8037
+ const errorMessage = extractErrorMessage(error, t);
8002
8038
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
8003
8039
  clearMessages();
8004
8040
  addMessage({
@@ -8234,7 +8270,6 @@ const handlePasskeyAuthentication = async (challengeData) => {
8234
8270
  //#endregion
8235
8271
  //#region src/components/auth/sign-in/v2/SignIn.ts
8236
8272
  const EXECUTION_ID_STORAGE_KEY = "thunderid_execution_id";
8237
- const AUTH_ID_STORAGE_KEY = "thunderid_auth_id";
8238
8273
  /**
8239
8274
  * SignIn — app-native sign-in component with full flow lifecycle management.
8240
8275
  *
@@ -8273,7 +8308,7 @@ const SignIn$1 = defineComponent({
8273
8308
  },
8274
8309
  emits: ["error", "success"],
8275
8310
  setup(props, { slots, emit, attrs }) {
8276
- const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading: sdkLoading } = useThunderID_default();
8311
+ const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading: sdkLoading, scopes, getStorageManager } = useThunderID_default();
8277
8312
  const { meta: flowMeta } = useFlowMeta_default();
8278
8313
  const { t } = useI18n_default();
8279
8314
  const components = ref([]);
@@ -8299,10 +8334,11 @@ const SignIn$1 = defineComponent({
8299
8334
  if (executionId) sessionStorage.setItem(EXECUTION_ID_STORAGE_KEY, executionId);
8300
8335
  else sessionStorage.removeItem(EXECUTION_ID_STORAGE_KEY);
8301
8336
  };
8302
- const clearFlowState = () => {
8337
+ const clearFlowState = async () => {
8303
8338
  persistExecutionId(null);
8304
8339
  isFlowInitialized.value = false;
8305
- sessionStorage.removeItem(AUTH_ID_STORAGE_KEY);
8340
+ const sm = getStorageManager();
8341
+ if (sm) await sm.removeHybridDataParameter("authId");
8306
8342
  isTimeoutDisabled.value = false;
8307
8343
  oauthCodeProcessedFlag.value = false;
8308
8344
  };
@@ -8349,7 +8385,10 @@ const SignIn$1 = defineComponent({
8349
8385
  const initializeFlow = async () => {
8350
8386
  const urlParams = getUrlParams$1();
8351
8387
  oauthCodeProcessedFlag.value = false;
8352
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8388
+ if (urlParams.authId) {
8389
+ const sm = getStorageManager();
8390
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8391
+ }
8353
8392
  const effectiveApplicationId = applicationId || urlParams.applicationId;
8354
8393
  if (!urlParams.executionId && !effectiveApplicationId) {
8355
8394
  const err = new ThunderIDRuntimeError$1("Either executionId or applicationId is required for authentication", "SIGN_IN_ERROR", "vue");
@@ -8362,13 +8401,17 @@ const SignIn$1 = defineComponent({
8362
8401
  if (urlParams.executionId) response = await signIn({ executionId: urlParams.executionId });
8363
8402
  else response = await signIn({
8364
8403
  applicationId: effectiveApplicationId,
8365
- flowType: EmbeddedFlowType.Authentication
8404
+ flowType: EmbeddedFlowType.Authentication,
8405
+ ...scopes && { scopes }
8366
8406
  });
8367
8407
  if (response.type === EmbeddedSignInFlowTypeV2.Redirection) {
8368
8408
  const redirectURL = response.data?.redirectURL || response?.redirectURL;
8369
8409
  if (redirectURL && window?.location) {
8370
8410
  if (response.executionId) persistExecutionId(response.executionId);
8371
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8411
+ if (urlParams.authId) {
8412
+ const sm = getStorageManager();
8413
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8414
+ }
8372
8415
  initiateOAuthRedirect(redirectURL);
8373
8416
  return;
8374
8417
  }
@@ -8385,8 +8428,7 @@ const SignIn$1 = defineComponent({
8385
8428
  } catch (error) {
8386
8429
  const err = error;
8387
8430
  clearFlowState();
8388
- const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
8389
- setError(new Error(errorMessage));
8431
+ setError(new Error(extractErrorMessage(err, t)));
8390
8432
  initializationAttempted = false;
8391
8433
  }
8392
8434
  };
@@ -8410,17 +8452,17 @@ const SignIn$1 = defineComponent({
8410
8452
  }
8411
8453
  const decisions = { purposes: purposes.map((p) => ({
8412
8454
  approved: !isDeny,
8413
- elements: [...(p.essential || []).map((attr) => ({
8455
+ elements: [...(p.essential ?? []).map((e) => ({
8414
8456
  approved: !isDeny,
8415
- name: attr
8416
- })), ...(p.optional || []).map((attr) => {
8417
- const key = `__consent_opt__${p.purpose_id}__${attr}`;
8457
+ name: e.name
8458
+ })), ...(p.optional ?? []).map((e) => {
8459
+ const key = `__consent_opt__${p.purposeId}__${e.name}`;
8418
8460
  return {
8419
8461
  approved: isDeny ? false : processedInputs[key] !== "false",
8420
- name: attr
8462
+ name: e.name
8421
8463
  };
8422
8464
  })],
8423
- purpose_name: p.purpose_name
8465
+ purposeName: p.purposeName
8424
8466
  })) };
8425
8467
  processedInputs["consent_decisions"] = JSON.stringify(decisions);
8426
8468
  Object.keys(processedInputs).forEach((key) => {
@@ -8440,7 +8482,10 @@ const SignIn$1 = defineComponent({
8440
8482
  if (redirectURL && window?.location) {
8441
8483
  if (response.executionId) persistExecutionId(response.executionId);
8442
8484
  const urlParams = getUrlParams$1();
8443
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8485
+ if (urlParams.authId) {
8486
+ const sm = getStorageManager();
8487
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8488
+ }
8444
8489
  initiateOAuthRedirect(redirectURL);
8445
8490
  return;
8446
8491
  }
@@ -8462,8 +8507,7 @@ const SignIn$1 = defineComponent({
8462
8507
  const { executionId: normalizedExecutionId, components: normalizedComponents, additionalData: normalizedAdditionalData } = normalizeFlowResponse(response, t, { resolveTranslations: false }, flowMeta.value);
8463
8508
  if (response.flowStatus === EmbeddedSignInFlowStatusV2.Error) {
8464
8509
  clearFlowState();
8465
- const failureReason = response?.failureReason || "Authentication flow failed. Please try again.";
8466
- const err = new Error(failureReason);
8510
+ const err = new Error(extractErrorMessage(response, t));
8467
8511
  setError(err);
8468
8512
  cleanupFlowUrlParams();
8469
8513
  throw err;
@@ -8473,7 +8517,8 @@ const SignIn$1 = defineComponent({
8473
8517
  isSubmitting.value = false;
8474
8518
  persistExecutionId(null);
8475
8519
  isFlowInitialized.value = false;
8476
- sessionStorage.removeItem(AUTH_ID_STORAGE_KEY);
8520
+ const sm = getStorageManager();
8521
+ if (sm) await sm.removeHybridDataParameter("authId");
8477
8522
  cleanupOAuthUrlParams();
8478
8523
  emit("success", {
8479
8524
  redirectUrl: finalRedirectUrl,
@@ -8489,14 +8534,13 @@ const SignIn$1 = defineComponent({
8489
8534
  isTimeoutDisabled.value = false;
8490
8535
  isFlowInitialized.value = true;
8491
8536
  cleanupFlowUrlParams();
8492
- if (response?.failureReason) flowError.value = new Error(response.failureReason);
8537
+ if (response?.error) flowError.value = new Error(extractErrorMessage(response, t));
8493
8538
  }
8494
8539
  } catch (error) {
8495
8540
  const err = error;
8496
8541
  if (err instanceof Error && flowError.value === err) throw err;
8497
8542
  clearFlowState();
8498
- const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
8499
- setError(new Error(errorMessage));
8543
+ setError(new Error(extractErrorMessage(err, t)));
8500
8544
  } finally {
8501
8545
  isSubmitting.value = false;
8502
8546
  }
@@ -8591,9 +8635,12 @@ const SignIn$1 = defineComponent({
8591
8635
  processedFlag: oauthCodeProcessedFlag,
8592
8636
  setExecutionId: persistExecutionId
8593
8637
  });
8594
- onMounted(() => {
8638
+ onMounted(async () => {
8595
8639
  const urlParams = getUrlParams$1();
8596
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8640
+ if (urlParams.authId) {
8641
+ const sm = getStorageManager();
8642
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8643
+ }
8597
8644
  });
8598
8645
  watch(() => [
8599
8646
  isInitialized.value,
@@ -9431,7 +9478,7 @@ const getAuthComponentHeadings = (components, flowTitle, flowSubtitle, defaultTi
9431
9478
  let subheading = null;
9432
9479
  const findHeadings = (comps) => {
9433
9480
  comps.some((component) => {
9434
- if (component.type === "TEXT" && component.variant && component.variant.startsWith("HEADING_")) {
9481
+ if (component.type === "TEXT" && component.variant?.startsWith("HEADING_")) {
9435
9482
  if (!heading) heading = component;
9436
9483
  else if (!subheading) {
9437
9484
  subheading = component;
@@ -9449,7 +9496,7 @@ const getAuthComponentHeadings = (components, flowTitle, flowSubtitle, defaultTi
9449
9496
  let foundHeadings = 0;
9450
9497
  const maxHeadings = 2;
9451
9498
  const filter = (items) => items.reduce((acc, component) => {
9452
- if (foundHeadings < maxHeadings && component.type === "TEXT" && component.variant && component.variant.startsWith("HEADING_")) {
9499
+ if (foundHeadings < maxHeadings && component.type === "TEXT" && component.variant?.startsWith("HEADING_")) {
9453
9500
  foundHeadings += 1;
9454
9501
  return acc;
9455
9502
  }
@@ -9609,7 +9656,7 @@ const BaseSignUp$1 = defineComponent({
9609
9656
  let initializationAttempted = false;
9610
9657
  let passkeyProcessed = false;
9611
9658
  const handleError = (error) => {
9612
- const errorMessage = error?.failureReason || extractErrorMessage(error, t);
9659
+ const errorMessage = extractErrorMessage(error, t);
9613
9660
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
9614
9661
  flowMessages.value = [{
9615
9662
  message: errorMessage,
@@ -9717,6 +9764,7 @@ const BaseSignUp$1 = defineComponent({
9717
9764
  else if (continueResponse.flowStatus === EmbeddedFlowStatus.Incomplete) {
9718
9765
  currentFlow.value = continueResponse;
9719
9766
  setupFormFields(continueResponse);
9767
+ if (continueResponse?.error) handleError(continueResponse);
9720
9768
  }
9721
9769
  popup.close();
9722
9770
  cleanup();
@@ -9807,6 +9855,7 @@ const BaseSignUp$1 = defineComponent({
9807
9855
  }
9808
9856
  currentFlow.value = response;
9809
9857
  setupFormFields(response);
9858
+ if (response?.error) handleError(response);
9810
9859
  }
9811
9860
  } catch (err) {
9812
9861
  handleError(err);
@@ -9839,6 +9888,7 @@ const BaseSignUp$1 = defineComponent({
9839
9888
  else {
9840
9889
  currentFlow.value = processed;
9841
9890
  setupFormFields(processed);
9891
+ if (processed?.error) handleError(processed);
9842
9892
  }
9843
9893
  passkeyState.value = {
9844
9894
  actionId: null,
@@ -9875,7 +9925,10 @@ const BaseSignUp$1 = defineComponent({
9875
9925
  props.onComplete?.(response);
9876
9926
  return;
9877
9927
  }
9878
- if (response.flowStatus === EmbeddedFlowStatus.Incomplete) setupFormFields(response);
9928
+ if (response.flowStatus === EmbeddedFlowStatus.Incomplete) {
9929
+ setupFormFields(response);
9930
+ if (response?.error) handleError(response);
9931
+ }
9879
9932
  } catch (err) {
9880
9933
  handleError(err);
9881
9934
  props.onError?.(err);
@@ -10018,13 +10071,14 @@ const SignUp$1 = defineComponent({
10018
10071
  }
10019
10072
  },
10020
10073
  setup(props, { slots }) {
10021
- const { signUp, isInitialized, applicationId } = useThunderID_default();
10074
+ const { signUp, isInitialized, applicationId, scopes } = useThunderID_default();
10022
10075
  const handleInitialize = async (payload) => {
10023
10076
  const applicationIdFromUrl = new URL(window.location.href).searchParams.get("applicationId");
10024
10077
  const effectiveApplicationId = applicationId || applicationIdFromUrl || void 0;
10025
10078
  return await signUp(payload || {
10026
10079
  flowType: EmbeddedFlowType.Registration,
10027
- ...effectiveApplicationId && { applicationId: effectiveApplicationId }
10080
+ ...effectiveApplicationId && { applicationId: effectiveApplicationId },
10081
+ ...scopes && { scopes }
10028
10082
  });
10029
10083
  };
10030
10084
  const handleOnSubmit = async (payload) => await signUp(payload);
@@ -10035,7 +10089,7 @@ const SignUp$1 = defineComponent({
10035
10089
  window.location.href = oauthRedirectUrl;
10036
10090
  return;
10037
10091
  }
10038
- if (props.shouldRedirectAfterSignUp && response?.type !== EmbeddedFlowResponseType.Redirection && props.afterSignUpUrl) window.location.href = props.afterSignUpUrl;
10092
+ if (props.shouldRedirectAfterSignUp && response?.type !== EmbeddedFlowResponseType.Redirection && props.afterSignUpUrl && !response?.assertion) window.location.href = props.afterSignUpUrl;
10039
10093
  if (props.shouldRedirectAfterSignUp && response?.type === EmbeddedFlowResponseType.Redirection && response?.data?.redirectURL && !response.data.redirectURL.includes("oauth") && !response.data.redirectURL.includes("auth")) window.location.href = response.data.redirectURL;
10040
10094
  };
10041
10095
  return () => h(BaseSignUp_default$2, {
@@ -10311,10 +10365,11 @@ const getDisplayName = (mergedMappings, user, displayAttributes) => {
10311
10365
  });
10312
10366
  if (foundValue !== void 0) return foundValue;
10313
10367
  }
10314
- const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
10315
- const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
10368
+ const mappings = mergedMappings;
10369
+ const firstName = getMappedUserProfileValue_default("firstName", mappings, user);
10370
+ const lastName = getMappedUserProfileValue_default("lastName", mappings, user);
10316
10371
  if (firstName && lastName) return `${firstName} ${lastName}`;
10317
- return getMappedUserProfileValue_default("username", mergedMappings, user) || getMappedUserProfileValue_default("email", mergedMappings, user) || getMappedUserProfileValue_default("name", mergedMappings, user) || "User";
10372
+ return getMappedUserProfileValue_default("username", mappings, user) || getMappedUserProfileValue_default("email", mappings, user) || getMappedUserProfileValue_default("name", mappings, user) || "User";
10318
10373
  };
10319
10374
  var getDisplayName_default = getDisplayName;
10320
10375
 
@@ -10508,7 +10563,7 @@ const BaseUserProfile = defineComponent({
10508
10563
  };
10509
10564
  }
10510
10565
  function cancelEditing(fieldName) {
10511
- const originalValue = (props.flattenedProfile || props.profile)?.[fieldName] ?? "";
10566
+ const originalValue = (props.flattenedProfile ?? props.profile ?? null)?.[fieldName] ?? "";
10512
10567
  editedValues.value = {
10513
10568
  ...editedValues.value,
10514
10569
  [fieldName]: originalValue
@@ -10529,7 +10584,7 @@ const BaseUserProfile = defineComponent({
10529
10584
  };
10530
10585
  }
10531
10586
  function renderInput(schema) {
10532
- const fieldName = schema.name;
10587
+ const fieldName = schema.name ?? "";
10533
10588
  const currentValue = editedValues.value[fieldName];
10534
10589
  switch (schema.type) {
10535
10590
  case "DATE_TIME": return h(DatePicker_default, {
@@ -10633,7 +10688,7 @@ const BaseUserProfile = defineComponent({
10633
10688
  }, [h("span", { class: px("user-profile__avatar-initials") }, initials)])]), h("div", { class: px("user-profile__hero-info") }, [h("span", { class: px("user-profile__hero-name") }, displayName), email ? h("span", { class: px("user-profile__hero-subtitle") }, String(email)) : null])]);
10634
10689
  }
10635
10690
  return () => {
10636
- const data = props.flattenedProfile || props.profile;
10691
+ const data = props.flattenedProfile ?? props.profile ?? null;
10637
10692
  if (!data && !props.isLoading) return slots["default"] ? slots["default"]({
10638
10693
  error: props.error,
10639
10694
  isLoading: props.isLoading,
@@ -10917,7 +10972,7 @@ const BaseUserDropdown = defineComponent({
10917
10972
  document.removeEventListener("keydown", handleKeyDown);
10918
10973
  });
10919
10974
  function resolveMenuAlign() {
10920
- if (props.menuAlign !== "auto") return props.menuAlign;
10975
+ if (props.menuAlign !== "auto") return props.menuAlign ?? "right";
10921
10976
  if (!containerRef.value) return "right";
10922
10977
  const rect = containerRef.value.getBoundingClientRect();
10923
10978
  const menuWidth = MENU_MIN_WIDTHS[props.size ?? "md"] ?? 220;
@@ -11178,7 +11233,7 @@ const BaseAcceptInvite = defineComponent({
11178
11233
  const isFormValid = ref(true);
11179
11234
  let tokenValidationAttempted = false;
11180
11235
  const handleError = (error) => {
11181
- const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.acceptInvite.errors.generic");
11236
+ const errorMessage = extractErrorMessage(error, t, "components.acceptInvite.errors.generic");
11182
11237
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
11183
11238
  props.onError?.(apiError.value);
11184
11239
  };
@@ -11315,6 +11370,7 @@ const BaseAcceptInvite = defineComponent({
11315
11370
  formValues.value = {};
11316
11371
  formErrors.value = {};
11317
11372
  touchedFields.value = {};
11373
+ if (response?.error) handleError(response);
11318
11374
  } catch (err) {
11319
11375
  handleError(err);
11320
11376
  } finally {
@@ -11379,6 +11435,7 @@ const BaseAcceptInvite = defineComponent({
11379
11435
  const meta = metaRef.value;
11380
11436
  if (slots["default"]) {
11381
11437
  const renderProps = {
11438
+ additionalData: currentFlow.value?.data?.additionalData ?? {},
11382
11439
  completionTitle: completionTitle.value,
11383
11440
  components,
11384
11441
  error: apiError.value,
@@ -11652,7 +11709,7 @@ const BaseInviteUser = defineComponent({
11652
11709
  const emailSent = ref(false);
11653
11710
  let initializationAttempted = false;
11654
11711
  const handleError = (error) => {
11655
- const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.inviteUser.errors.generic");
11712
+ const errorMessage = extractErrorMessage(error, t, "components.inviteUser.errors.generic");
11656
11713
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
11657
11714
  props.onError?.(apiError.value);
11658
11715
  };
@@ -11750,6 +11807,7 @@ const BaseInviteUser = defineComponent({
11750
11807
  formValues.value = {};
11751
11808
  formErrors.value = {};
11752
11809
  touchedFields.value = {};
11810
+ if (response?.error) handleError(response);
11753
11811
  } catch (err) {
11754
11812
  handleError(err);
11755
11813
  } finally {