@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.
@@ -166,8 +166,10 @@ const FlowMetaProvider = (0, vue.defineComponent)({
166
166
  try {
167
167
  meta.value = await (0, __thunderid_browser.getFlowMetaV2)({
168
168
  baseUrl,
169
- id: applicationId,
170
- type: __thunderid_browser.FlowMetaType.App
169
+ ...applicationId ? {
170
+ id: applicationId,
171
+ type: __thunderid_browser.FlowMetaType.App
172
+ } : {}
171
173
  });
172
174
  } catch (err) {
173
175
  error.value = err instanceof Error ? err : new Error(String(err));
@@ -182,9 +184,11 @@ const FlowMetaProvider = (0, vue.defineComponent)({
182
184
  try {
183
185
  const result = await (0, __thunderid_browser.getFlowMetaV2)({
184
186
  baseUrl,
185
- id: applicationId,
186
- language,
187
- type: __thunderid_browser.FlowMetaType.App
187
+ ...applicationId ? {
188
+ id: applicationId,
189
+ type: __thunderid_browser.FlowMetaType.App
190
+ } : {},
191
+ language
188
192
  });
189
193
  if (result.i18n?.translations && i18nContext?.injectBundles) {
190
194
  const flatTranslations = {};
@@ -946,7 +950,7 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
946
950
  async getUser(options) {
947
951
  try {
948
952
  let baseUrl = options?.baseUrl;
949
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
953
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
950
954
  return (0, __thunderid_browser.generateUserProfile)(await getScim2Me_default({ baseUrl }), (0, __thunderid_browser.flattenUserSchema)(await getSchemas_default({ baseUrl })));
951
955
  } catch (error) {
952
956
  return (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken());
@@ -962,7 +966,7 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
962
966
  return this.withLoading(async () => {
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
  const profile = await getScim2Me_default({
967
971
  baseUrl,
968
972
  instanceId: this.getInstanceId()
@@ -988,7 +992,7 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
988
992
  async getMyOrganizations(options) {
989
993
  try {
990
994
  let baseUrl = options?.baseUrl;
991
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
995
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
992
996
  return await getMeOrganizations_default({
993
997
  baseUrl,
994
998
  instanceId: this.getInstanceId()
@@ -1000,7 +1004,7 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1000
1004
  async getAllOrganizations(options) {
1001
1005
  try {
1002
1006
  let baseUrl = options?.baseUrl;
1003
- if (!baseUrl) baseUrl = this.getStorageManager().getConfigData()?.baseUrl;
1007
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
1004
1008
  return await getAllOrganizations_default({
1005
1009
  baseUrl,
1006
1010
  instanceId: this.getInstanceId()
@@ -1014,9 +1018,9 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1014
1018
  return await this.withLoading(async () => {
1015
1019
  const idToken = await this.getDecodedIdToken();
1016
1020
  return {
1017
- id: idToken?.org_id,
1018
- name: idToken?.org_name,
1019
- orgHandle: idToken?.org_handle
1021
+ id: idToken?.org_id ?? "",
1022
+ name: idToken?.org_name ?? "",
1023
+ orgHandle: idToken?.org_handle ?? ""
1020
1024
  };
1021
1025
  });
1022
1026
  } catch (error) {
@@ -1026,7 +1030,7 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1026
1030
  async switchOrganization(organization) {
1027
1031
  return this.withLoading(async () => {
1028
1032
  try {
1029
- const sourceInstanceId = this.getStorageManager().getConfigData()?.organizationChain?.sourceInstanceId;
1033
+ const sourceInstanceId = (await this.getStorageManager().getConfigData())?.organizationChain?.sourceInstanceId;
1030
1034
  if (!organization.id) throw new __thunderid_browser.ThunderIDRuntimeError("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.");
1031
1035
  const exchangeConfig = {
1032
1036
  attachToken: false,
@@ -1065,14 +1069,12 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1065
1069
  const arg2 = args[1];
1066
1070
  if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
1067
1071
  if (typeof arg1 === "object" && arg1 !== null && !(0, __thunderid_browser.isEmpty)(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
1068
- const configData = this.getStorageManager().getConfigData();
1072
+ const configData = await this.getStorageManager().getConfigData();
1069
1073
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
1070
- const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
1071
- const authId = authIdFromUrl || authIdFromStorage;
1072
- const baseUrlFromStorage = sessionStorage.getItem("thunderid_base_url");
1074
+ const authIdFromStorage = await this.getStorageManager().getHybridDataParameter("authId");
1073
1075
  const response = await (0, __thunderid_browser.executeEmbeddedSignInFlowV2)({
1074
- authId,
1075
- baseUrl: configData?.baseUrl || baseUrlFromStorage,
1076
+ authId: authIdFromUrl || authIdFromStorage || "",
1077
+ baseUrl: configData?.baseUrl || "",
1076
1078
  payload: arg1,
1077
1079
  url: arg2?.url
1078
1080
  });
@@ -1099,14 +1101,14 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1099
1101
  return await super.signInSilently(options);
1100
1102
  }
1101
1103
  async signUp(...args) {
1102
- const configData = this.getStorageManager().getConfigData();
1104
+ const configData = await this.getStorageManager().getConfigData();
1103
1105
  const firstArg = args[0];
1104
- const baseUrl = configData?.baseUrl;
1106
+ const baseUrl = configData?.baseUrl || "";
1105
1107
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
1106
- const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
1107
- const authId = authIdFromUrl || authIdFromStorage;
1108
- if (authIdFromUrl && !authIdFromStorage) sessionStorage.setItem("thunderid_auth_id", authIdFromUrl);
1109
- return (0, __thunderid_browser.executeEmbeddedSignUpFlowV2)({
1108
+ const authIdFromStorage = await this.getStorageManager().getHybridDataParameter("authId");
1109
+ const authId = authIdFromUrl || authIdFromStorage || "";
1110
+ if (authIdFromUrl && !authIdFromStorage) await this.getStorageManager().setHybridDataParameter("authId", authIdFromUrl);
1111
+ const response = await (0, __thunderid_browser.executeEmbeddedSignUpFlowV2)({
1110
1112
  authId,
1111
1113
  baseUrl,
1112
1114
  payload: typeof firstArg === "object" && "flowType" in firstArg ? {
@@ -1114,12 +1116,27 @@ var ThunderIDVueClient = class extends __thunderid_browser.ThunderIDBrowserClien
1114
1116
  verbose: true
1115
1117
  } : firstArg
1116
1118
  });
1119
+ if (response && typeof response === "object" && response.flowStatus === __thunderid_browser.EmbeddedSignUpFlowStatusV2.Complete && response.assertion) {
1120
+ const decodedAssertion = await this.decodeJwtToken(response.assertion);
1121
+ const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
1122
+ const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
1123
+ await this.setSession({
1124
+ access_token: response.assertion,
1125
+ created_at: createdAt,
1126
+ expires_in: expiresIn,
1127
+ id_token: response.assertion,
1128
+ scope: decodedAssertion.scope,
1129
+ token_type: "Bearer"
1130
+ });
1131
+ this.notifySignIn((0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedAssertion));
1132
+ }
1133
+ return response;
1117
1134
  }
1118
1135
  async request(requestConfig) {
1119
- return this.httpRequest(requestConfig);
1136
+ return await this.httpRequest(requestConfig);
1120
1137
  }
1121
1138
  async requestAll(requestConfigs) {
1122
- return this.httpRequestAll(requestConfigs);
1139
+ return await this.httpRequestAll(requestConfigs);
1123
1140
  }
1124
1141
  async getAccessToken(sessionId) {
1125
1142
  return super.getAccessToken(sessionId);
@@ -1203,7 +1220,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1203
1220
  },
1204
1221
  scopes: {
1205
1222
  default: void 0,
1206
- type: Array
1223
+ type: [Array, String]
1207
1224
  },
1208
1225
  signInOptions: {
1209
1226
  default: void 0,
@@ -1241,8 +1258,8 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1241
1258
  let loadingCheckInterval;
1242
1259
  function buildConfig() {
1243
1260
  return {
1244
- afterSignInUrl: props.afterSignInUrl,
1245
- afterSignOutUrl: props.afterSignOutUrl,
1261
+ afterSignInUrl: props.afterSignInUrl ?? window.location.origin,
1262
+ afterSignOutUrl: props.afterSignOutUrl ?? window.location.origin,
1246
1263
  applicationId: props.applicationId,
1247
1264
  baseUrl: props.baseUrl,
1248
1265
  clientId: props.clientId,
@@ -1337,10 +1354,12 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1337
1354
  await client.clearSession(...args);
1338
1355
  },
1339
1356
  clientId: props.clientId,
1357
+ scopes: props.scopes,
1340
1358
  exchangeToken: (config) => client.exchangeToken(config),
1341
1359
  getAccessToken: () => client.getAccessToken(),
1342
1360
  getDecodedIdToken: () => client.getDecodedIdToken(),
1343
1361
  getIdToken: () => client.getIdToken(),
1362
+ getStorageManager: () => client.getStorageManager(),
1344
1363
  http: {
1345
1364
  request: (requestConfig) => client.request(requestConfig),
1346
1365
  requestAll: (requestConfigs) => client.requestAll(requestConfigs)
@@ -1370,7 +1389,8 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1370
1389
  (0, vue.onMounted)(async () => {
1371
1390
  const config = buildConfig();
1372
1391
  await client.initialize(config);
1373
- const initializedConfig = client.getConfiguration();
1392
+ await client.getDiscoveryResponse();
1393
+ const initializedConfig = await client.getConfiguration();
1374
1394
  if (initializedConfig?.baseUrl) sessionStorage.setItem("thunderid_base_url", initializedConfig.baseUrl);
1375
1395
  try {
1376
1396
  isInitialized.value = await client.isInitialized();
@@ -1423,7 +1443,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1423
1443
  onUpdateProfile: (updatedUser) => {
1424
1444
  user.value = updatedUser;
1425
1445
  userProfile.value = {
1426
- flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(updatedUser, userProfile.value?.schemas),
1446
+ flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(updatedUser, userProfile.value?.schemas ?? []),
1427
1447
  profile: updatedUser,
1428
1448
  schemas: userProfile.value?.schemas ?? []
1429
1449
  };
@@ -7368,7 +7388,7 @@ const BaseSignIn$2 = (0, vue.defineComponent)({
7368
7388
  onSubmit: (e) => {
7369
7389
  e.preventDefault();
7370
7390
  const fd = {};
7371
- currentAuthenticator.value.metadata?.params?.forEach((p) => {
7391
+ currentAuthenticator.value?.metadata?.params?.forEach((p) => {
7372
7392
  fd[p.param] = formValues.value[p.param] || "";
7373
7393
  });
7374
7394
  handleSubmit(fd);
@@ -7525,7 +7545,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7525
7545
  case __thunderid_browser.EmbeddedFlowComponentTypeV2.TextInput:
7526
7546
  case __thunderid_browser.EmbeddedFlowComponentTypeV2.PasswordInput:
7527
7547
  case __thunderid_browser.EmbeddedFlowComponentTypeV2.EmailInput: {
7528
- const identifier = component.ref;
7548
+ const identifier = component.ref ?? "";
7529
7549
  const value = formValues[identifier] || "";
7530
7550
  const error = touchedFields[identifier] || false ? formErrors[identifier] : void 0;
7531
7551
  const fieldType = getFieldType(component.type);
@@ -7559,14 +7579,14 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7559
7579
  const isDeny = componentVariant.toLowerCase() !== "primary";
7560
7580
  const decisions = { purposes: consentPrompt.purposes.map((p) => ({
7561
7581
  approved: !isDeny,
7562
- elements: [...p.essential.map((attr) => ({
7582
+ elements: [...p.essential.map((e) => ({
7563
7583
  approved: !isDeny,
7564
- name: attr
7565
- })), ...p.optional.map((attr) => ({
7566
- approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, attr)] !== "false",
7567
- name: attr
7584
+ name: e.name
7585
+ })), ...p.optional.map((e) => ({
7586
+ approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, e.name)] !== "false",
7587
+ name: e.name
7568
7588
  }))],
7569
- purposeName: p.purposeName
7589
+ purposeName: p.purposeName ?? ""
7570
7590
  })) };
7571
7591
  formData["consent_decisions"] = JSON.stringify(decisions);
7572
7592
  }
@@ -7627,7 +7647,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7627
7647
  }, { default: () => buttonText || "Submit" });
7628
7648
  }
7629
7649
  case __thunderid_browser.EmbeddedFlowComponentTypeV2.Text: {
7630
- const variant = getTypographyVariant(component.variant);
7650
+ const variant = getTypographyVariant(component.variant ?? "");
7631
7651
  return (0, vue.h)(Typography_default, {
7632
7652
  key,
7633
7653
  style: {
@@ -7642,7 +7662,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7642
7662
  return (0, vue.h)(Divider_default, { key }, dividerLabel ? { default: () => dividerLabel } : void 0);
7643
7663
  }
7644
7664
  case __thunderid_browser.EmbeddedFlowComponentTypeV2.Select: {
7645
- const identifier = component.ref;
7665
+ const identifier = component.ref ?? "";
7646
7666
  const value = formValues[identifier] || "";
7647
7667
  const error = touchedFields[identifier] || false ? formErrors[identifier] : void 0;
7648
7668
  const selectOptions = (component.options || []).map((opt) => ({
@@ -7744,7 +7764,7 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
7744
7764
  const renderSignInComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7745
7765
  ...options,
7746
7766
  key: component.id || index
7747
- })).filter(Boolean);
7767
+ })).filter((v) => v !== null);
7748
7768
  /**
7749
7769
  * Processes an array of components and renders them as VNodes for sign-up.
7750
7770
  * Identical to renderSignInComponents — separated for semantic clarity.
@@ -7752,7 +7772,7 @@ const renderSignInComponents = (components, formValues, touchedFields, formError
7752
7772
  const renderSignUpComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7753
7773
  ...options,
7754
7774
  key: component.id || index
7755
- })).filter(Boolean);
7775
+ })).filter((v) => v !== null);
7756
7776
  /**
7757
7777
  * Processes an array of components and renders them as VNodes for invite-user flows.
7758
7778
  * Identical to renderSignInComponents — separated for semantic clarity.
@@ -7760,7 +7780,7 @@ const renderSignUpComponents = (components, formValues, touchedFields, formError
7760
7780
  const renderInviteUserComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map((component, index) => createAuthComponentFromFlow(component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, {
7761
7781
  ...options,
7762
7782
  key: component.id || index
7763
- })).filter(Boolean);
7783
+ })).filter((v) => v !== null);
7764
7784
 
7765
7785
  //#endregion
7766
7786
  //#region src/utils/v2/resolveTranslationsInObject.ts
@@ -7866,10 +7886,26 @@ const transformComponents = (response, t, resolveTranslations = true, meta) => {
7866
7886
  };
7867
7887
  /**
7868
7888
  * Extract error message from flow error response.
7869
- * Supports any flow error response that follows the standard structure.
7870
- * Prioritizes failureReason if present, otherwise falls back to translated generic message.
7889
+ *
7890
+ * Resolution order:
7891
+ * 1. Structured `error` object: try i18n lookup via `t(error.message.key)`.
7892
+ * 2. Fallback to `defaultValue` from `message`, then `description`.
7893
+ * 3. Standard `Error.message`.
7894
+ * 4. Generic translated fallback via `defaultErrorKey`.
7871
7895
  */
7872
7896
  const extractErrorMessage = (error, t, defaultErrorKey = "errors.flow.generic") => {
7897
+ if (error && typeof error === "object" && error.error) {
7898
+ const flowError = error.error;
7899
+ if (flowError?.message?.key) {
7900
+ const translated = t(flowError.message.key);
7901
+ if (translated && translated !== flowError.message.key) return translated;
7902
+ const systemKey = `system.${flowError.message.key}`;
7903
+ const systemTranslated = t(systemKey);
7904
+ if (systemTranslated && systemTranslated !== systemKey) return systemTranslated;
7905
+ }
7906
+ const fallback = flowError?.message?.defaultValue ?? flowError?.description?.defaultValue;
7907
+ if (fallback) return fallback;
7908
+ }
7873
7909
  if (error && typeof error === "object" && error.failureReason) return error.failureReason;
7874
7910
  if (error instanceof Error && error.message) return error.message;
7875
7911
  return t(defaultErrorKey);
@@ -8024,7 +8060,7 @@ const BaseSignIn$1 = (0, vue.defineComponent)({
8024
8060
  });
8025
8061
  const isFormValid = (0, vue.computed)(() => Object.keys(formErrors.value).length === 0);
8026
8062
  const handleError = (error) => {
8027
- const errorMessage = error?.failureReason || extractErrorMessage(error, t);
8063
+ const errorMessage = extractErrorMessage(error, t);
8028
8064
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
8029
8065
  clearMessages();
8030
8066
  addMessage({
@@ -8260,7 +8296,6 @@ const handlePasskeyAuthentication = async (challengeData) => {
8260
8296
  //#endregion
8261
8297
  //#region src/components/auth/sign-in/v2/SignIn.ts
8262
8298
  const EXECUTION_ID_STORAGE_KEY = "thunderid_execution_id";
8263
- const AUTH_ID_STORAGE_KEY = "thunderid_auth_id";
8264
8299
  /**
8265
8300
  * SignIn — app-native sign-in component with full flow lifecycle management.
8266
8301
  *
@@ -8299,7 +8334,7 @@ const SignIn$1 = (0, vue.defineComponent)({
8299
8334
  },
8300
8335
  emits: ["error", "success"],
8301
8336
  setup(props, { slots, emit, attrs }) {
8302
- const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading: sdkLoading } = useThunderID_default();
8337
+ const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading: sdkLoading, scopes, getStorageManager } = useThunderID_default();
8303
8338
  const { meta: flowMeta } = useFlowMeta_default();
8304
8339
  const { t } = useI18n_default();
8305
8340
  const components = (0, vue.ref)([]);
@@ -8325,10 +8360,11 @@ const SignIn$1 = (0, vue.defineComponent)({
8325
8360
  if (executionId) sessionStorage.setItem(EXECUTION_ID_STORAGE_KEY, executionId);
8326
8361
  else sessionStorage.removeItem(EXECUTION_ID_STORAGE_KEY);
8327
8362
  };
8328
- const clearFlowState = () => {
8363
+ const clearFlowState = async () => {
8329
8364
  persistExecutionId(null);
8330
8365
  isFlowInitialized.value = false;
8331
- sessionStorage.removeItem(AUTH_ID_STORAGE_KEY);
8366
+ const sm = getStorageManager();
8367
+ if (sm) await sm.removeHybridDataParameter("authId");
8332
8368
  isTimeoutDisabled.value = false;
8333
8369
  oauthCodeProcessedFlag.value = false;
8334
8370
  };
@@ -8375,7 +8411,10 @@ const SignIn$1 = (0, vue.defineComponent)({
8375
8411
  const initializeFlow = async () => {
8376
8412
  const urlParams = getUrlParams$1();
8377
8413
  oauthCodeProcessedFlag.value = false;
8378
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8414
+ if (urlParams.authId) {
8415
+ const sm = getStorageManager();
8416
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8417
+ }
8379
8418
  const effectiveApplicationId = applicationId || urlParams.applicationId;
8380
8419
  if (!urlParams.executionId && !effectiveApplicationId) {
8381
8420
  const err = new __thunderid_browser.ThunderIDRuntimeError("Either executionId or applicationId is required for authentication", "SIGN_IN_ERROR", "vue");
@@ -8388,13 +8427,17 @@ const SignIn$1 = (0, vue.defineComponent)({
8388
8427
  if (urlParams.executionId) response = await signIn({ executionId: urlParams.executionId });
8389
8428
  else response = await signIn({
8390
8429
  applicationId: effectiveApplicationId,
8391
- flowType: __thunderid_browser.EmbeddedFlowType.Authentication
8430
+ flowType: __thunderid_browser.EmbeddedFlowType.Authentication,
8431
+ ...scopes && { scopes }
8392
8432
  });
8393
8433
  if (response.type === __thunderid_browser.EmbeddedSignInFlowTypeV2.Redirection) {
8394
8434
  const redirectURL = response.data?.redirectURL || response?.redirectURL;
8395
8435
  if (redirectURL && window?.location) {
8396
8436
  if (response.executionId) persistExecutionId(response.executionId);
8397
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8437
+ if (urlParams.authId) {
8438
+ const sm = getStorageManager();
8439
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8440
+ }
8398
8441
  initiateOAuthRedirect(redirectURL);
8399
8442
  return;
8400
8443
  }
@@ -8411,8 +8454,7 @@ const SignIn$1 = (0, vue.defineComponent)({
8411
8454
  } catch (error) {
8412
8455
  const err = error;
8413
8456
  clearFlowState();
8414
- const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
8415
- setError(new Error(errorMessage));
8457
+ setError(new Error(extractErrorMessage(err, t)));
8416
8458
  initializationAttempted = false;
8417
8459
  }
8418
8460
  };
@@ -8436,17 +8478,17 @@ const SignIn$1 = (0, vue.defineComponent)({
8436
8478
  }
8437
8479
  const decisions = { purposes: purposes.map((p) => ({
8438
8480
  approved: !isDeny,
8439
- elements: [...(p.essential || []).map((attr) => ({
8481
+ elements: [...(p.essential ?? []).map((e) => ({
8440
8482
  approved: !isDeny,
8441
- name: attr
8442
- })), ...(p.optional || []).map((attr) => {
8443
- const key = `__consent_opt__${p.purpose_id}__${attr}`;
8483
+ name: e.name
8484
+ })), ...(p.optional ?? []).map((e) => {
8485
+ const key = `__consent_opt__${p.purposeId}__${e.name}`;
8444
8486
  return {
8445
8487
  approved: isDeny ? false : processedInputs[key] !== "false",
8446
- name: attr
8488
+ name: e.name
8447
8489
  };
8448
8490
  })],
8449
- purpose_name: p.purpose_name
8491
+ purposeName: p.purposeName
8450
8492
  })) };
8451
8493
  processedInputs["consent_decisions"] = JSON.stringify(decisions);
8452
8494
  Object.keys(processedInputs).forEach((key) => {
@@ -8466,7 +8508,10 @@ const SignIn$1 = (0, vue.defineComponent)({
8466
8508
  if (redirectURL && window?.location) {
8467
8509
  if (response.executionId) persistExecutionId(response.executionId);
8468
8510
  const urlParams = getUrlParams$1();
8469
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8511
+ if (urlParams.authId) {
8512
+ const sm = getStorageManager();
8513
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8514
+ }
8470
8515
  initiateOAuthRedirect(redirectURL);
8471
8516
  return;
8472
8517
  }
@@ -8488,8 +8533,7 @@ const SignIn$1 = (0, vue.defineComponent)({
8488
8533
  const { executionId: normalizedExecutionId, components: normalizedComponents, additionalData: normalizedAdditionalData } = normalizeFlowResponse(response, t, { resolveTranslations: false }, flowMeta.value);
8489
8534
  if (response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatusV2.Error) {
8490
8535
  clearFlowState();
8491
- const failureReason = response?.failureReason || "Authentication flow failed. Please try again.";
8492
- const err = new Error(failureReason);
8536
+ const err = new Error(extractErrorMessage(response, t));
8493
8537
  setError(err);
8494
8538
  cleanupFlowUrlParams();
8495
8539
  throw err;
@@ -8499,7 +8543,8 @@ const SignIn$1 = (0, vue.defineComponent)({
8499
8543
  isSubmitting.value = false;
8500
8544
  persistExecutionId(null);
8501
8545
  isFlowInitialized.value = false;
8502
- sessionStorage.removeItem(AUTH_ID_STORAGE_KEY);
8546
+ const sm = getStorageManager();
8547
+ if (sm) await sm.removeHybridDataParameter("authId");
8503
8548
  cleanupOAuthUrlParams();
8504
8549
  emit("success", {
8505
8550
  redirectUrl: finalRedirectUrl,
@@ -8515,14 +8560,13 @@ const SignIn$1 = (0, vue.defineComponent)({
8515
8560
  isTimeoutDisabled.value = false;
8516
8561
  isFlowInitialized.value = true;
8517
8562
  cleanupFlowUrlParams();
8518
- if (response?.failureReason) flowError.value = new Error(response.failureReason);
8563
+ if (response?.error) flowError.value = new Error(extractErrorMessage(response, t));
8519
8564
  }
8520
8565
  } catch (error) {
8521
8566
  const err = error;
8522
8567
  if (err instanceof Error && flowError.value === err) throw err;
8523
8568
  clearFlowState();
8524
- const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
8525
- setError(new Error(errorMessage));
8569
+ setError(new Error(extractErrorMessage(err, t)));
8526
8570
  } finally {
8527
8571
  isSubmitting.value = false;
8528
8572
  }
@@ -8617,9 +8661,12 @@ const SignIn$1 = (0, vue.defineComponent)({
8617
8661
  processedFlag: oauthCodeProcessedFlag,
8618
8662
  setExecutionId: persistExecutionId
8619
8663
  });
8620
- (0, vue.onMounted)(() => {
8664
+ (0, vue.onMounted)(async () => {
8621
8665
  const urlParams = getUrlParams$1();
8622
- if (urlParams.authId) sessionStorage.setItem(AUTH_ID_STORAGE_KEY, urlParams.authId);
8666
+ if (urlParams.authId) {
8667
+ const sm = getStorageManager();
8668
+ if (sm) await sm.setHybridDataParameter("authId", urlParams.authId);
8669
+ }
8623
8670
  });
8624
8671
  (0, vue.watch)(() => [
8625
8672
  isInitialized.value,
@@ -9457,7 +9504,7 @@ const getAuthComponentHeadings = (components, flowTitle, flowSubtitle, defaultTi
9457
9504
  let subheading = null;
9458
9505
  const findHeadings = (comps) => {
9459
9506
  comps.some((component) => {
9460
- if (component.type === "TEXT" && component.variant && component.variant.startsWith("HEADING_")) {
9507
+ if (component.type === "TEXT" && component.variant?.startsWith("HEADING_")) {
9461
9508
  if (!heading) heading = component;
9462
9509
  else if (!subheading) {
9463
9510
  subheading = component;
@@ -9475,7 +9522,7 @@ const getAuthComponentHeadings = (components, flowTitle, flowSubtitle, defaultTi
9475
9522
  let foundHeadings = 0;
9476
9523
  const maxHeadings = 2;
9477
9524
  const filter = (items) => items.reduce((acc, component) => {
9478
- if (foundHeadings < maxHeadings && component.type === "TEXT" && component.variant && component.variant.startsWith("HEADING_")) {
9525
+ if (foundHeadings < maxHeadings && component.type === "TEXT" && component.variant?.startsWith("HEADING_")) {
9479
9526
  foundHeadings += 1;
9480
9527
  return acc;
9481
9528
  }
@@ -9635,7 +9682,7 @@ const BaseSignUp$1 = (0, vue.defineComponent)({
9635
9682
  let initializationAttempted = false;
9636
9683
  let passkeyProcessed = false;
9637
9684
  const handleError = (error) => {
9638
- const errorMessage = error?.failureReason || extractErrorMessage(error, t);
9685
+ const errorMessage = extractErrorMessage(error, t);
9639
9686
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
9640
9687
  flowMessages.value = [{
9641
9688
  message: errorMessage,
@@ -9743,6 +9790,7 @@ const BaseSignUp$1 = (0, vue.defineComponent)({
9743
9790
  else if (continueResponse.flowStatus === __thunderid_browser.EmbeddedFlowStatus.Incomplete) {
9744
9791
  currentFlow.value = continueResponse;
9745
9792
  setupFormFields(continueResponse);
9793
+ if (continueResponse?.error) handleError(continueResponse);
9746
9794
  }
9747
9795
  popup.close();
9748
9796
  cleanup();
@@ -9833,6 +9881,7 @@ const BaseSignUp$1 = (0, vue.defineComponent)({
9833
9881
  }
9834
9882
  currentFlow.value = response;
9835
9883
  setupFormFields(response);
9884
+ if (response?.error) handleError(response);
9836
9885
  }
9837
9886
  } catch (err) {
9838
9887
  handleError(err);
@@ -9865,6 +9914,7 @@ const BaseSignUp$1 = (0, vue.defineComponent)({
9865
9914
  else {
9866
9915
  currentFlow.value = processed;
9867
9916
  setupFormFields(processed);
9917
+ if (processed?.error) handleError(processed);
9868
9918
  }
9869
9919
  passkeyState.value = {
9870
9920
  actionId: null,
@@ -9901,7 +9951,10 @@ const BaseSignUp$1 = (0, vue.defineComponent)({
9901
9951
  props.onComplete?.(response);
9902
9952
  return;
9903
9953
  }
9904
- if (response.flowStatus === __thunderid_browser.EmbeddedFlowStatus.Incomplete) setupFormFields(response);
9954
+ if (response.flowStatus === __thunderid_browser.EmbeddedFlowStatus.Incomplete) {
9955
+ setupFormFields(response);
9956
+ if (response?.error) handleError(response);
9957
+ }
9905
9958
  } catch (err) {
9906
9959
  handleError(err);
9907
9960
  props.onError?.(err);
@@ -10044,13 +10097,14 @@ const SignUp$1 = (0, vue.defineComponent)({
10044
10097
  }
10045
10098
  },
10046
10099
  setup(props, { slots }) {
10047
- const { signUp, isInitialized, applicationId } = useThunderID_default();
10100
+ const { signUp, isInitialized, applicationId, scopes } = useThunderID_default();
10048
10101
  const handleInitialize = async (payload) => {
10049
10102
  const applicationIdFromUrl = new URL(window.location.href).searchParams.get("applicationId");
10050
10103
  const effectiveApplicationId = applicationId || applicationIdFromUrl || void 0;
10051
10104
  return await signUp(payload || {
10052
10105
  flowType: __thunderid_browser.EmbeddedFlowType.Registration,
10053
- ...effectiveApplicationId && { applicationId: effectiveApplicationId }
10106
+ ...effectiveApplicationId && { applicationId: effectiveApplicationId },
10107
+ ...scopes && { scopes }
10054
10108
  });
10055
10109
  };
10056
10110
  const handleOnSubmit = async (payload) => await signUp(payload);
@@ -10061,7 +10115,7 @@ const SignUp$1 = (0, vue.defineComponent)({
10061
10115
  window.location.href = oauthRedirectUrl;
10062
10116
  return;
10063
10117
  }
10064
- if (props.shouldRedirectAfterSignUp && response?.type !== __thunderid_browser.EmbeddedFlowResponseType.Redirection && props.afterSignUpUrl) window.location.href = props.afterSignUpUrl;
10118
+ if (props.shouldRedirectAfterSignUp && response?.type !== __thunderid_browser.EmbeddedFlowResponseType.Redirection && props.afterSignUpUrl && !response?.assertion) window.location.href = props.afterSignUpUrl;
10065
10119
  if (props.shouldRedirectAfterSignUp && response?.type === __thunderid_browser.EmbeddedFlowResponseType.Redirection && response?.data?.redirectURL && !response.data.redirectURL.includes("oauth") && !response.data.redirectURL.includes("auth")) window.location.href = response.data.redirectURL;
10066
10120
  };
10067
10121
  return () => (0, vue.h)(BaseSignUp_default$2, {
@@ -10337,10 +10391,11 @@ const getDisplayName = (mergedMappings, user, displayAttributes) => {
10337
10391
  });
10338
10392
  if (foundValue !== void 0) return foundValue;
10339
10393
  }
10340
- const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
10341
- const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
10394
+ const mappings = mergedMappings;
10395
+ const firstName = getMappedUserProfileValue_default("firstName", mappings, user);
10396
+ const lastName = getMappedUserProfileValue_default("lastName", mappings, user);
10342
10397
  if (firstName && lastName) return `${firstName} ${lastName}`;
10343
- return getMappedUserProfileValue_default("username", mergedMappings, user) || getMappedUserProfileValue_default("email", mergedMappings, user) || getMappedUserProfileValue_default("name", mergedMappings, user) || "User";
10398
+ return getMappedUserProfileValue_default("username", mappings, user) || getMappedUserProfileValue_default("email", mappings, user) || getMappedUserProfileValue_default("name", mappings, user) || "User";
10344
10399
  };
10345
10400
  var getDisplayName_default = getDisplayName;
10346
10401
 
@@ -10534,7 +10589,7 @@ const BaseUserProfile = (0, vue.defineComponent)({
10534
10589
  };
10535
10590
  }
10536
10591
  function cancelEditing(fieldName) {
10537
- const originalValue = (props.flattenedProfile || props.profile)?.[fieldName] ?? "";
10592
+ const originalValue = (props.flattenedProfile ?? props.profile ?? null)?.[fieldName] ?? "";
10538
10593
  editedValues.value = {
10539
10594
  ...editedValues.value,
10540
10595
  [fieldName]: originalValue
@@ -10555,7 +10610,7 @@ const BaseUserProfile = (0, vue.defineComponent)({
10555
10610
  };
10556
10611
  }
10557
10612
  function renderInput(schema) {
10558
- const fieldName = schema.name;
10613
+ const fieldName = schema.name ?? "";
10559
10614
  const currentValue = editedValues.value[fieldName];
10560
10615
  switch (schema.type) {
10561
10616
  case "DATE_TIME": return (0, vue.h)(DatePicker_default, {
@@ -10659,7 +10714,7 @@ const BaseUserProfile = (0, vue.defineComponent)({
10659
10714
  }, [(0, vue.h)("span", { class: px("user-profile__avatar-initials") }, initials)])]), (0, vue.h)("div", { class: px("user-profile__hero-info") }, [(0, vue.h)("span", { class: px("user-profile__hero-name") }, displayName), email ? (0, vue.h)("span", { class: px("user-profile__hero-subtitle") }, String(email)) : null])]);
10660
10715
  }
10661
10716
  return () => {
10662
- const data = props.flattenedProfile || props.profile;
10717
+ const data = props.flattenedProfile ?? props.profile ?? null;
10663
10718
  if (!data && !props.isLoading) return slots["default"] ? slots["default"]({
10664
10719
  error: props.error,
10665
10720
  isLoading: props.isLoading,
@@ -10943,7 +10998,7 @@ const BaseUserDropdown = (0, vue.defineComponent)({
10943
10998
  document.removeEventListener("keydown", handleKeyDown);
10944
10999
  });
10945
11000
  function resolveMenuAlign() {
10946
- if (props.menuAlign !== "auto") return props.menuAlign;
11001
+ if (props.menuAlign !== "auto") return props.menuAlign ?? "right";
10947
11002
  if (!containerRef.value) return "right";
10948
11003
  const rect = containerRef.value.getBoundingClientRect();
10949
11004
  const menuWidth = MENU_MIN_WIDTHS[props.size ?? "md"] ?? 220;
@@ -11204,7 +11259,7 @@ const BaseAcceptInvite = (0, vue.defineComponent)({
11204
11259
  const isFormValid = (0, vue.ref)(true);
11205
11260
  let tokenValidationAttempted = false;
11206
11261
  const handleError = (error) => {
11207
- const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.acceptInvite.errors.generic");
11262
+ const errorMessage = extractErrorMessage(error, t, "components.acceptInvite.errors.generic");
11208
11263
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
11209
11264
  props.onError?.(apiError.value);
11210
11265
  };
@@ -11341,6 +11396,7 @@ const BaseAcceptInvite = (0, vue.defineComponent)({
11341
11396
  formValues.value = {};
11342
11397
  formErrors.value = {};
11343
11398
  touchedFields.value = {};
11399
+ if (response?.error) handleError(response);
11344
11400
  } catch (err) {
11345
11401
  handleError(err);
11346
11402
  } finally {
@@ -11405,6 +11461,7 @@ const BaseAcceptInvite = (0, vue.defineComponent)({
11405
11461
  const meta = metaRef.value;
11406
11462
  if (slots["default"]) {
11407
11463
  const renderProps = {
11464
+ additionalData: currentFlow.value?.data?.additionalData ?? {},
11408
11465
  completionTitle: completionTitle.value,
11409
11466
  components,
11410
11467
  error: apiError.value,
@@ -11678,7 +11735,7 @@ const BaseInviteUser = (0, vue.defineComponent)({
11678
11735
  const emailSent = (0, vue.ref)(false);
11679
11736
  let initializationAttempted = false;
11680
11737
  const handleError = (error) => {
11681
- const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.inviteUser.errors.generic");
11738
+ const errorMessage = extractErrorMessage(error, t, "components.inviteUser.errors.generic");
11682
11739
  apiError.value = error instanceof Error ? error : new Error(errorMessage);
11683
11740
  props.onError?.(apiError.value);
11684
11741
  };
@@ -11776,6 +11833,7 @@ const BaseInviteUser = (0, vue.defineComponent)({
11776
11833
  formValues.value = {};
11777
11834
  formErrors.value = {};
11778
11835
  touchedFields.value = {};
11836
+ if (response?.error) handleError(response);
11779
11837
  } catch (err) {
11780
11838
  handleError(err);
11781
11839
  } finally {