@thunderid/vue 1.10.3 → 1.11.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.
@@ -8644,6 +8644,7 @@ const BaseSignIn = (0, vue.defineComponent)({
8644
8644
  const isLoading = (0, vue.computed)(() => props.isLoading || isSubmitting.value);
8645
8645
  const formValues = (0, vue.ref)({});
8646
8646
  const touchedFields = (0, vue.ref)({});
8647
+ const serverFormErrors = (0, vue.ref)({});
8647
8648
  (0, vue.watch)(() => props.components, (newComponents) => {
8648
8649
  const fields = extractFormFields$1(newComponents || []);
8649
8650
  const freshValues = { ...props.initialValues };
@@ -8652,6 +8653,7 @@ const BaseSignIn = (0, vue.defineComponent)({
8652
8653
  });
8653
8654
  formValues.value = freshValues;
8654
8655
  touchedFields.value = {};
8656
+ serverFormErrors.value = {};
8655
8657
  }, {
8656
8658
  deep: false,
8657
8659
  immediate: true
@@ -8662,12 +8664,24 @@ const BaseSignIn = (0, vue.defineComponent)({
8662
8664
  ...initialValues
8663
8665
  };
8664
8666
  }, { deep: true });
8665
- const formErrors = (0, vue.computed)(() => {
8666
- const fields = extractFormFields$1(props.components || []);
8667
+ (0, vue.watch)(() => props.serverFieldErrors, (fieldErrors) => {
8667
8668
  const errors = {};
8668
- (props.serverFieldErrors ?? []).forEach((fieldError) => {
8669
- if (!(fieldError.identifier in errors)) errors[fieldError.identifier] = fieldError.message;
8669
+ const touched = {};
8670
+ (fieldErrors ?? []).forEach((fieldError) => {
8671
+ if (!(fieldError.identifier in errors)) {
8672
+ errors[fieldError.identifier] = fieldError.message;
8673
+ touched[fieldError.identifier] = true;
8674
+ }
8670
8675
  });
8676
+ serverFormErrors.value = errors;
8677
+ if (Object.keys(touched).length > 0) touchedFields.value = {
8678
+ ...touchedFields.value,
8679
+ ...touched
8680
+ };
8681
+ }, { immediate: true });
8682
+ const formErrors = (0, vue.computed)(() => {
8683
+ const fields = extractFormFields$1(props.components || []);
8684
+ const errors = { ...serverFormErrors.value };
8671
8685
  fields.forEach((field) => {
8672
8686
  const value = formValues.value[field.name] || "";
8673
8687
  const isTouched = touchedFields.value[field.name] || false;
@@ -8691,6 +8705,11 @@ const BaseSignIn = (0, vue.defineComponent)({
8691
8705
  ...formValues.value,
8692
8706
  [name]: value
8693
8707
  };
8708
+ if (name in serverFormErrors.value) {
8709
+ const errors = { ...serverFormErrors.value };
8710
+ delete errors[name];
8711
+ serverFormErrors.value = errors;
8712
+ }
8694
8713
  };
8695
8714
  const handleInputBlur = (name) => {
8696
8715
  touchedFields.value = {
@@ -9111,39 +9130,24 @@ const SignIn = (0, vue.defineComponent)({
9111
9130
  const handleSubmit = async (payload) => {
9112
9131
  const effectiveExecutionId = payload.executionId || currentExecutionId.value;
9113
9132
  if (!effectiveExecutionId) throw new Error("No active flow ID");
9114
- const processedInputs = { ...payload.inputs };
9133
+ let processedInputs = { ...payload.inputs };
9115
9134
  if (additionalData.value?.["consentPrompt"]) try {
9116
9135
  const consentRaw = additionalData.value["consentPrompt"];
9117
9136
  const purposes = typeof consentRaw === "string" ? JSON.parse(consentRaw) : consentRaw.purposes || consentRaw;
9118
9137
  let isDeny = false;
9119
9138
  if (payload.action) {
9120
- const findAction = (comps) => {
9139
+ const findAction$1 = (comps) => {
9121
9140
  if (!comps?.length) return null;
9122
9141
  const found = comps.find((c) => c.id === payload.action);
9123
9142
  if (found) return found;
9124
- return comps.reduce((acc, c) => acc || (c.components ? findAction(c.components) : null), null);
9143
+ return comps.reduce((acc, c) => acc || (c.components ? findAction$1(c.components) : null), null);
9125
9144
  };
9126
- const submitAction = findAction(components.value);
9145
+ const submitAction = findAction$1(components.value);
9127
9146
  if (submitAction && submitAction.variant?.toLowerCase() !== "primary") isDeny = true;
9128
9147
  }
9129
- const decisions = {
9148
+ processedInputs = (0, __thunderid_browser.compileConsentDecisions)(processedInputs, purposes, {
9130
9149
  approved: !isDeny,
9131
- ...isDeny ? { reason: __thunderid_browser.ConsentConstants.REASON_USER_DENIED } : {},
9132
- purposes: purposes.map((p) => ({
9133
- approved: !isDeny,
9134
- elements: [...(p.essential ?? []).map((e) => ({
9135
- approved: !isDeny,
9136
- name: e.name
9137
- })), ...(p.optional ?? []).map((e) => {
9138
- const key = getConsentOptionalKey(p.purposeId, e.name);
9139
- return (0, __thunderid_browser.getConsentElementDecision)(p.purposeId, e, !isDeny && processedInputs[key] === "true", processedInputs);
9140
- })],
9141
- purposeName: p.purposeName
9142
- }))
9143
- };
9144
- processedInputs["consent_decisions"] = JSON.stringify(decisions);
9145
- Object.keys(processedInputs).forEach((key) => {
9146
- if (key.startsWith("__consent_opt__") || key.startsWith(__thunderid_browser.CONSENT_MODIFIED_KEY_PREFIX) || key.startsWith(__thunderid_browser.CONSENT_INVALID_KEY_PREFIX)) delete processedInputs[key];
9150
+ ...isDeny ? { reason: __thunderid_browser.ConsentConstants.REASON_USER_DENIED } : {}
9147
9151
  });
9148
9152
  } catch {}
9149
9153
  try {
@@ -9417,6 +9421,10 @@ const BaseDeviceGrant = (0, vue.defineComponent)({
9417
9421
  default: false,
9418
9422
  type: Boolean
9419
9423
  },
9424
+ isTimeoutDisabled: {
9425
+ default: false,
9426
+ type: Boolean
9427
+ },
9420
9428
  error: {
9421
9429
  default: null,
9422
9430
  type: Object
@@ -9473,6 +9481,7 @@ const BaseDeviceGrant = (0, vue.defineComponent)({
9473
9481
  error: props.error,
9474
9482
  initialValues: props.initialValues,
9475
9483
  isLoading: props.isLoading,
9484
+ isTimeoutDisabled: props.isTimeoutDisabled,
9476
9485
  onSubmit: props.onSubmit,
9477
9486
  serverFieldErrors: props.serverFieldErrors,
9478
9487
  size: props.size,
@@ -9488,7 +9497,51 @@ var BaseDeviceGrant_default = BaseDeviceGrant;
9488
9497
 
9489
9498
  //#endregion
9490
9499
  //#region src/components/auth/device-grant/DeviceGrant.ts
9500
+ const toDeviceGrantError = (cause, fallbackMessage) => {
9501
+ if (cause instanceof __thunderid_browser.ThunderIDAPIError || cause instanceof __thunderid_browser.ThunderIDRuntimeError) return cause;
9502
+ return new __thunderid_browser.ThunderIDRuntimeError(cause instanceof Error ? cause.message : fallbackMessage, "DEVICE_GRANT_ERROR", "vue", cause);
9503
+ };
9491
9504
  const hasUserCodeInput = (components) => components.some((component) => component.ref === "user_code" || Array.isArray(component.components) && hasUserCodeInput(component.components));
9505
+ const findAction = (components, actionId) => {
9506
+ for (const component of components) {
9507
+ if (component.id === actionId) return component;
9508
+ if (component.components) {
9509
+ const nestedAction = findAction(component.components, actionId);
9510
+ if (nestedAction) return nestedAction;
9511
+ }
9512
+ }
9513
+ };
9514
+ const parseConsentPurposes = (value) => {
9515
+ let parsed = value;
9516
+ if (typeof parsed === "string") try {
9517
+ parsed = JSON.parse(parsed);
9518
+ } catch {
9519
+ return null;
9520
+ }
9521
+ if (Array.isArray(parsed)) return parsed;
9522
+ if (typeof parsed === "object" && parsed !== null && "purposes" in parsed && Array.isArray(parsed.purposes)) return parsed.purposes;
9523
+ return null;
9524
+ };
9525
+ const CONSENT_REASON_KEY = "__consent_reason__";
9526
+ const flattenComponents = (items) => items.flatMap((component) => [component, ...flattenComponents(component.components ?? [])]);
9527
+ const findConsentSubmitActionId = (items) => {
9528
+ const actions = flattenComponents(items).filter((component) => component.id && component.eventType?.toUpperCase() === "SUBMIT");
9529
+ return (actions.find((component) => component.variant?.toLowerCase() !== "primary") ?? actions[0])?.id;
9530
+ };
9531
+ const compileConsentInputs = (inputs, actionId, components, additionalData) => {
9532
+ const action = actionId ? findAction(components, actionId) : void 0;
9533
+ const purposes = parseConsentPurposes(additionalData["consentPrompt"]);
9534
+ const consentReason = inputs[CONSENT_REASON_KEY];
9535
+ const cleanInputs = { ...inputs };
9536
+ delete cleanInputs[CONSENT_REASON_KEY];
9537
+ const isSubmitAction = Boolean(action && action.eventType?.toUpperCase() !== "TRIGGER");
9538
+ const isTimeout = consentReason === __thunderid_browser.ConsentConstants.REASON_TIMEOUT;
9539
+ const isDeny = isTimeout || Boolean(action && isSubmitAction && action.variant?.toLowerCase() !== "primary");
9540
+ return (0, __thunderid_browser.compileConsentDecisions)(cleanInputs, isSubmitAction ? purposes : null, {
9541
+ approved: !isDeny,
9542
+ ...isTimeout ? { reason: __thunderid_browser.ConsentConstants.REASON_TIMEOUT } : isDeny ? { reason: __thunderid_browser.ConsentConstants.REASON_USER_DENIED } : {}
9543
+ });
9544
+ };
9492
9545
  /** Runs the application's configured Device Grant flow and exposes its state for custom renderers. */
9493
9546
  const DeviceGrant = (0, vue.defineComponent)({
9494
9547
  name: "DeviceGrant",
@@ -9504,19 +9557,11 @@ const DeviceGrant = (0, vue.defineComponent)({
9504
9557
  variant: {
9505
9558
  default: "flat",
9506
9559
  type: String
9507
- },
9508
- onComplete: {
9509
- default: void 0,
9510
- type: Function
9511
- },
9512
- onError: {
9513
- default: void 0,
9514
- type: Function
9515
9560
  }
9516
9561
  },
9517
9562
  emits: ["complete", "error"],
9518
9563
  setup(props, { emit, slots }) {
9519
- const { applicationId, baseUrl } = useThunderID_default();
9564
+ const { applicationId, baseUrl, getStorageManager, isInitialized, isLoading: sdkLoading, vendor } = useThunderID_default();
9520
9565
  const { meta } = useFlowMeta_default();
9521
9566
  const { t } = useI18n_default();
9522
9567
  const components = (0, vue.ref)([]);
@@ -9525,28 +9570,61 @@ const DeviceGrant = (0, vue.defineComponent)({
9525
9570
  const serverFieldErrors = (0, vue.ref)(null);
9526
9571
  const executionId = (0, vue.ref)("");
9527
9572
  const challengeToken = (0, vue.ref)("");
9573
+ const challengeTokenRef = { current: "" };
9574
+ const isStorageReady = (0, vue.ref)(false);
9528
9575
  const error = (0, vue.ref)(null);
9529
9576
  const isLoading = (0, vue.ref)(false);
9577
+ const isTimeoutDisabled = (0, vue.ref)(false);
9530
9578
  const result = (0, vue.ref)(null);
9531
9579
  const flowStartAttempted = (0, vue.ref)(false);
9532
- const applyResponse = (response) => {
9580
+ const executionIdStorageKey = `${vendor}_device_grant_execution_id`;
9581
+ const oauthCodeProcessedFlag = { value: false };
9582
+ const persistExecutionId = (id) => {
9583
+ executionId.value = id ?? "";
9584
+ if (id) sessionStorage.setItem(executionIdStorageKey, id);
9585
+ else sessionStorage.removeItem(executionIdStorageKey);
9586
+ };
9587
+ const persistChallengeToken = async (token) => {
9588
+ challengeTokenRef.current = token ?? "";
9589
+ challengeToken.value = token ?? "";
9590
+ try {
9591
+ const storageManager = getStorageManager?.();
9592
+ if (storageManager) if (token) await storageManager.setTemporaryDataParameter("challengeToken", token);
9593
+ else await storageManager.removeTemporaryDataParameter("challengeToken");
9594
+ } catch {}
9595
+ };
9596
+ const handleError = (flowError) => {
9597
+ components.value = [];
9598
+ additionalData.value = {};
9599
+ serverFieldErrors.value = null;
9600
+ error.value = flowError;
9601
+ result.value = "failure";
9602
+ emit("error", flowError);
9603
+ };
9604
+ const applyResponse = async (response) => {
9605
+ const redirectURL = response.data?.redirectURL ?? response.redirectUrl;
9606
+ if (response.type === __thunderid_browser.EmbeddedSignInFlowType.Redirection && typeof redirectURL === "string") {
9607
+ persistExecutionId(response.executionId ?? null);
9608
+ await persistChallengeToken(response.challengeToken ?? null);
9609
+ initiateOAuthRedirect(redirectURL, vendor);
9610
+ return;
9611
+ }
9533
9612
  const normalized = normalizeFlowResponse(response, t, { resolveTranslations: false }, meta.value);
9534
- executionId.value = response.executionId ?? "";
9535
- challengeToken.value = response.challengeToken ?? "";
9613
+ persistExecutionId(response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Incomplete ? response.executionId ?? null : null);
9614
+ await persistChallengeToken(response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Incomplete ? response.challengeToken ?? null : null);
9536
9615
  components.value = normalized.components ?? [];
9537
9616
  additionalData.value = normalized.additionalData ?? {};
9617
+ isTimeoutDisabled.value = false;
9538
9618
  serverFieldErrors.value = response.data?.fieldErrors ?? null;
9539
9619
  error.value = response.error ? new Error(extractErrorMessage(response, t)) : null;
9540
9620
  if (response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Complete) {
9541
9621
  result.value = "success";
9542
- props.onComplete?.(response);
9543
9622
  emit("complete", response);
9544
9623
  return;
9545
9624
  }
9546
9625
  if (response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Error) {
9547
- error.value = new Error(extractErrorMessage(response, t, "deviceGrant.messages.failed"));
9626
+ error.value = new __thunderid_browser.ThunderIDRuntimeError(extractErrorMessage(response, t, "deviceGrant.messages.failed"), "DEVICE_GRANT_ERROR", "vue");
9548
9627
  result.value = "failure";
9549
- props.onError?.(error.value);
9550
9628
  emit("error", error.value);
9551
9629
  return;
9552
9630
  }
@@ -9558,29 +9636,36 @@ const DeviceGrant = (0, vue.defineComponent)({
9558
9636
  url.searchParams.delete("applicationId");
9559
9637
  window.history.replaceState(window.history.state, "", url.toString());
9560
9638
  };
9561
- const startFlow = async (appId) => {
9639
+ const startFlow = async (appId, resumeId) => {
9562
9640
  isLoading.value = true;
9563
9641
  error.value = null;
9564
9642
  try {
9565
- const response = await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9566
- baseUrl,
9567
- payload: {
9568
- applicationId: appId,
9569
- flowType: __thunderid_browser.EmbeddedFlowType.DeviceGrant,
9570
- inputs: {}
9643
+ const challengeFromStorage = challengeTokenRef.current;
9644
+ let response;
9645
+ try {
9646
+ response = await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9647
+ baseUrl,
9648
+ payload: resumeId ? {
9649
+ executionId: resumeId,
9650
+ ...challengeFromStorage ? { challengeToken: challengeFromStorage } : {}
9651
+ } : {
9652
+ applicationId: appId,
9653
+ flowType: __thunderid_browser.EmbeddedFlowType.DeviceGrant,
9654
+ inputs: {}
9655
+ }
9656
+ });
9657
+ } catch (resumeError) {
9658
+ if (resumeId && resumeError instanceof __thunderid_browser.ThunderIDAPIError && resumeError.statusCode === 400) {
9659
+ persistExecutionId(null);
9660
+ await persistChallengeToken(null);
9661
+ throw new __thunderid_browser.ThunderIDRuntimeError(t("deviceGrant.errors.continue"), "DEVICE_GRANT_ERROR", "vue");
9571
9662
  }
9572
- });
9573
- clearVerificationParameters();
9574
- applyResponse(response);
9663
+ throw resumeError;
9664
+ }
9665
+ if (!resumeId) clearVerificationParameters();
9666
+ await applyResponse(response);
9575
9667
  } catch (cause) {
9576
- const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9577
- components.value = [];
9578
- additionalData.value = {};
9579
- serverFieldErrors.value = null;
9580
- error.value = flowError;
9581
- result.value = "failure";
9582
- props.onError?.(flowError);
9583
- emit("error", flowError);
9668
+ handleError(toDeviceGrantError(cause, t("deviceGrant.errors.continue")));
9584
9669
  } finally {
9585
9670
  isLoading.value = false;
9586
9671
  }
@@ -9591,48 +9676,121 @@ const DeviceGrant = (0, vue.defineComponent)({
9591
9676
  result.value = null;
9592
9677
  try {
9593
9678
  if (!executionId.value) return;
9594
- const inputs = Object.fromEntries(Object.entries(payload.inputs ?? {}).filter(([key]) => !key.startsWith("__consent_opt__")));
9679
+ const action = payload.action ?? actionId;
9680
+ const inputs = compileConsentInputs(payload.inputs ?? {}, action, components.value, additionalData.value);
9595
9681
  if (!hasUserCodeInput(components.value)) delete inputs["user_code"];
9596
- applyResponse(await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9682
+ await applyResponse(await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9597
9683
  baseUrl,
9598
9684
  payload: {
9599
- action: payload.action ?? actionId,
9685
+ action,
9600
9686
  challengeToken: challengeToken.value,
9601
9687
  executionId: executionId.value,
9602
9688
  inputs
9603
9689
  }
9604
9690
  }));
9605
9691
  } catch (cause) {
9606
- const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9607
- components.value = [];
9608
- additionalData.value = {};
9609
- serverFieldErrors.value = null;
9610
- error.value = flowError;
9611
- result.value = "failure";
9612
- props.onError?.(flowError);
9613
- emit("error", flowError);
9692
+ handleError(toDeviceGrantError(cause, t("deviceGrant.errors.continue")));
9614
9693
  } finally {
9615
9694
  isLoading.value = false;
9616
9695
  }
9617
9696
  };
9618
- (0, vue.onMounted)(() => {
9697
+ let timeoutHandle = null;
9698
+ let timeoutSubmittedFor = null;
9699
+ (0, vue.watch)(() => [additionalData.value["stepTimeout"], executionId.value], ([stepTimeout, activeExecutionId]) => {
9700
+ if (timeoutHandle) clearTimeout(timeoutHandle);
9701
+ timeoutHandle = null;
9702
+ const timeoutMs = Number(stepTimeout) || 0;
9703
+ if (timeoutMs <= 0 || !activeExecutionId) {
9704
+ isTimeoutDisabled.value = false;
9705
+ return;
9706
+ }
9707
+ timeoutHandle = setTimeout(() => {
9708
+ isTimeoutDisabled.value = true;
9709
+ const expiredError = new __thunderid_browser.ThunderIDRuntimeError(t("errors.signin.timeout") || "Time allowed to complete the step has expired.", "DEVICE_GRANT_ERROR", "vue");
9710
+ const actionId = additionalData.value["consentPrompt"] ? findConsentSubmitActionId(components.value) : void 0;
9711
+ if (actionId && timeoutSubmittedFor !== timeoutMs) {
9712
+ timeoutSubmittedFor = timeoutMs;
9713
+ submit({
9714
+ action: actionId,
9715
+ inputs: { [CONSENT_REASON_KEY]: __thunderid_browser.ConsentConstants.REASON_TIMEOUT }
9716
+ }, actionId);
9717
+ return;
9718
+ }
9719
+ handleError(expiredError);
9720
+ }, Math.max(0, timeoutMs - Date.now()));
9721
+ });
9722
+ (0, vue.onUnmounted)(() => {
9723
+ if (timeoutHandle) clearTimeout(timeoutHandle);
9724
+ });
9725
+ const sdkReady = isInitialized ?? (0, vue.ref)(true);
9726
+ const sdkIsLoading = sdkLoading ?? (0, vue.ref)(false);
9727
+ const callbackReady = (0, vue.computed)(() => sdkReady.value && !sdkIsLoading.value && isStorageReady.value);
9728
+ (0, vue.watch)(() => [sdkReady.value, sdkIsLoading.value], async ([ready, loading]) => {
9729
+ if (!ready || loading || isStorageReady.value) return;
9730
+ try {
9731
+ const storedChallengeToken = (await getStorageManager?.()?.getTemporaryData())?.["challengeToken"];
9732
+ if (typeof storedChallengeToken === "string") {
9733
+ challengeTokenRef.current = storedChallengeToken;
9734
+ challengeToken.value = storedChallengeToken;
9735
+ }
9736
+ } catch {} finally {
9737
+ isStorageReady.value = true;
9738
+ }
9739
+ }, { immediate: true });
9740
+ useOAuthCallback({
9741
+ currentFlowId: executionId,
9742
+ flowIdStorageKey: executionIdStorageKey,
9743
+ isInitialized: callbackReady,
9744
+ isSubmitting: isLoading,
9745
+ onError: (cause) => {
9746
+ persistExecutionId(null);
9747
+ persistChallengeToken(null);
9748
+ handleError(toDeviceGrantError(cause, String(cause)));
9749
+ },
9750
+ onFlowChange: (response) => void applyResponse(response),
9751
+ onSubmit: async (payload) => {
9752
+ isLoading.value = true;
9753
+ try {
9754
+ return await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9755
+ baseUrl,
9756
+ payload: {
9757
+ challengeToken: challengeTokenRef.current || challengeToken.value,
9758
+ executionId: payload.flowId,
9759
+ inputs: payload.inputs
9760
+ }
9761
+ });
9762
+ } finally {
9763
+ isLoading.value = false;
9764
+ }
9765
+ },
9766
+ processedFlag: oauthCodeProcessedFlag,
9767
+ setFlowId: persistExecutionId
9768
+ });
9769
+ (0, vue.watch)(() => [
9770
+ sdkReady.value,
9771
+ sdkIsLoading.value,
9772
+ isStorageReady.value
9773
+ ], async ([ready, loading, storageReady]) => {
9774
+ if (!ready || loading || !storageReady || flowStartAttempted.value) return;
9619
9775
  const url = new URL(window.location.href);
9620
9776
  const code = url.searchParams.get("user_code");
9621
9777
  if (code) initialValues.value = { user_code: code };
9622
9778
  const applicationIdFromUrl = url.searchParams.get("applicationId");
9623
9779
  const appId = applicationIdFromUrl?.trim() ? applicationIdFromUrl : applicationId;
9624
- if (!appId) {
9625
- const flowError = new Error(t("deviceGrant.errors.start"));
9780
+ if (url.searchParams.has("code") || url.searchParams.has("state") || url.searchParams.has("error") || oauthCodeProcessedFlag.value) return;
9781
+ const storedExecutionId = sessionStorage.getItem(executionIdStorageKey);
9782
+ if (!appId && !storedExecutionId) {
9783
+ flowStartAttempted.value = true;
9784
+ const flowError = new __thunderid_browser.ThunderIDRuntimeError(t("deviceGrant.errors.start"), "DEVICE_GRANT_ERROR", "vue");
9626
9785
  error.value = flowError;
9627
9786
  result.value = "failure";
9628
- props.onError?.(flowError);
9629
9787
  emit("error", flowError);
9630
9788
  return;
9631
9789
  }
9632
9790
  if (flowStartAttempted.value) return;
9633
9791
  flowStartAttempted.value = true;
9634
- startFlow(appId);
9635
- });
9792
+ await startFlow(appId ?? "", storedExecutionId ?? void 0);
9793
+ }, { immediate: true });
9636
9794
  return () => (0, vue.h)(BaseDeviceGrant_default, {
9637
9795
  className: props.className,
9638
9796
  components: components.value,
@@ -9640,6 +9798,7 @@ const DeviceGrant = (0, vue.defineComponent)({
9640
9798
  error: error.value,
9641
9799
  initialValues: initialValues.value,
9642
9800
  isLoading: isLoading.value,
9801
+ isTimeoutDisabled: isTimeoutDisabled.value,
9643
9802
  onSubmit: (payload, component) => submit(payload, component.id),
9644
9803
  result: result.value,
9645
9804
  serverFieldErrors: serverFieldErrors.value,
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDeviceGrant.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/device-grant/BaseDeviceGrant.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,KAAK,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAC,KAAK,SAAS,EAAmE,MAAM,KAAK,CAAC;AAKrG,OAAO,KAAK,EAAC,qBAAqB,EAAE,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAElF,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;AAE7D,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,eAAe,GAAG,UAAU,CAAC;IAC9G,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,aAAa,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aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,yFAAyF;AACzF,QAAA,MAAM,eAAe,EAAE,SA4FrB,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceGrant.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/device-grant/DeviceGrant.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,KAAK,SAAS,EAAmF,MAAM,KAAK,CAAC;AAErH,OAAO,KAAK,EAAC,0BAA0B,EAAoB,MAAM,mBAAmB,CAAC;AAMrF,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAgBhE,sGAAsG;AACtG,QAAA,MAAM,WAAW,EAAE,SAsKjB,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"DeviceGrant.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/device-grant/DeviceGrant.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,SAAS,EAWf,MAAM,KAAK,CAAC;AAEb,OAAO,KAAK,EAAC,0BAA0B,EAAoB,MAAM,mBAAmB,CAAC;AAkBrF,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAgFhE,sGAAsG;AACtG,QAAA,MAAM,WAAW,EAAE,SA6TjB,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSignIn.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/sign-in/BaseSignIn.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,yBAAyB,EACzB,qBAAqB,EACrB,UAAU,EACV,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,KAAK,SAAS,EAUf,MAAM,KAAK,CAAC;AAWb;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,UAAU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,EAAE,SAAS,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnG,iBAAiB,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;CAC5C;AAwBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,UAAU,EAAE,SA0VhB,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/sign-in/SignIn.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,qBAAqB,EAErB,yBAAyB,EAIzB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,SAAS,EAWf,MAAM,KAAK,CAAC;AAoBb;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,MAAM,EAAE,SAsmBZ,CAAC;AAEH,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../../src/components/auth/sign-in/SignIn.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,qBAAqB,EAErB,yBAAyB,EAIzB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,SAAS,EAWf,MAAM,KAAK,CAAC;AAmBb;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,MAAM,EAAE,SA2kBZ,CAAC;AAEH,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ADMINISTRATION_FLOW_TYPE, APPLICATION_GRANT_TYPES, AccountLifecycleFlowConfigKey, AccountLifecycleFlowConfigKey as AccountLifecycleFlowConfigKey$1, AdministrationFlowConfigKey, AdministrationFlowData, AdministrationFlowError, AdministrationFlowInput, AdministrationModes, AgentQueryKeys, AgentQueryKeys as AgentQueryKeys$1, ApplicationQueryKeys, ApplicationQueryKeys as ApplicationQueryKeys$1, AuthFlowSelectConstants, CONSENT_INVALID_KEY_PREFIX, CONSENT_MODIFIED_KEY_PREFIX, ConsentConstants, CredentialConstants, DEFAULT_APPLICATION_GRANT_TYPES, DEFAULT_THEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowEventType, EmbeddedFlowEventType as EmbeddedFlowEventType$1, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowType, EmbeddedSignInFlowType as EmbeddedSignInFlowType$1, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatus$1, EmbeddedSignUpFlowType, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, GroupQueryKeys, GroupQueryKeys as GroupQueryKeys$1, RoleQueryKeys, RoleQueryKeys as RoleQueryKeys$1, SPAUtils, SelectConstants, ThunderIDAPIError, ThunderIDAPIError as ThunderIDAPIError$1, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, ThunderIDWordmark, TranslationBundleConstants, UserQueryKeys, UserQueryKeys as UserQueryKeys$1, UserSelectConstants, UserTypeSelectConstants, addGroupMembers, addGroupMembers as addGroupMembers$1, addRoleAssignments, addRoleAssignments as addRoleAssignments$1, applyGatewayConfiguration, arrayBufferToBase64url, base64urlToArrayBuffer, bem, copyTextToClipboard, createAction, createAgent, createAgent as createAgent$1, createAgentType, createApplication, createApplication as createApplication$1, createApplicationSharingPolicy, createClassObserver, createClassObserver as createClassObserver$1, createConfigurationVersion, createConnection, createDesignTheme, createFlow, createGateway, createGatewaySecret, createGatewayVariable, createGroup, createGroup as createGroup$1, createHttpClientFetcher, createLayout, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createNotificationTemplate, createOrganizationUnit, createPackageComponentLogger, createPackageLogger, createResource, createResourceInvalidator, createResourceInvalidator as createResourceInvalidator$1, createResourceOptionsLoader, createResourceServer, createRole, createRole as createRole$1, createSecret, createTheme, createUser, createUser as createUser$1, createUserByPath, createUserSharingPolicy, createUserType, createVariable, deepMerge, deleteAction, deleteAgent, deleteAgent as deleteAgent$1, deleteAgentType, deleteApplication, deleteApplication as deleteApplication$1, deleteApplicationSharingPolicy, deleteConnection, deleteDesignTheme, deleteFlow, deleteGateway, deleteGatewaySecret, deleteGatewayVariable, deleteGroup, deleteImportedConfiguration, deleteLayout, deleteNotificationTemplate, deleteOrganizationUnit, deleteOrganizationUnitByPath, deleteResource, deleteResourceServer, deleteRole, deleteSecret, deleteTranslation, deleteTranslations, deleteUser, deleteUser as deleteUser$1, deleteUserSharingPolicy, deleteUserType, deleteVariable, detectThemeMode, detectThemeMode as detectThemeMode$1, evaluateChangePasswordForm, executeAdministrationFlow, executeEmbeddedDeviceGrantFlow, executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow, exportConfiguration, extractEmojiFromUri, extractUserClaimsFromIdToken, fallbackResourceInvalidator, findAdministrationFlows, generateFlattenedUserProfile, get, getAccountLifecycleActions, getAccountLifecycleActions as getAccountLifecycleActions$1, getAction, getActions, getActiveTheme, getAgent, getAgent as getAgent$1, getAgentGroups, getAgentGroups as getAgentGroups$1, getAgentName, getAgentName as getAgentName$1, getAgentRoles, getAgentRoles as getAgentRoles$1, getAgentType, getAgentTypes, getAgentTypes as getAgentTypes$1, getAgents, getAgents as getAgents$1, getApplication, getApplication as getApplication$1, getApplicationClientSecret, getApplicationOAuthConfig, getApplicationOverlayRules, getApplicationSharingPolicies, getApplicationSharingPolicy, getApplications, getApplications as getApplications$1, getConfigurationVersion, getConfigurationVersions, getConnection, getConnectionUsages, getConnections, getConnectionsMeta, getConsentElementDecision, getDefaultI18nBundles, getDesignTheme, getDesignThemeUsages, getDesignThemes, getFlow, getFlowMeta, getFlowUsages, getFlowVersion, getFlowVersions, getFlows, getFlows as getFlows$1, getGateway, getGatewayAppliedConfiguration, getGatewayAppliedVersion, getGatewayConfigurationDiff, getGatewaySecret, getGatewaySecrets, getGatewayVariable, getGatewayVariables, getGateways, getGroup, getGroupMembers, getGroupMembers as getGroupMembers$1, getGroups, getGroups as getGroups$1, getLanguages, getLayout, getLayoutUsages, getLayouts, getNotificationTemplate, getNotificationTemplates, getOrganizationUnit, getOrganizationUnitByPath, getOrganizationUnitChildren, getOrganizationUnitGroups, getOrganizationUnitRoles, getOrganizationUnitUsers, getOrganizationUnits, getResource, getResourceServer, getResourceServers, getResources, getRole, getRole as getRole$1, getRoleAssignments, getRoleAssignments as getRoleAssignments$1, getRoles, getRoles as getRoles$1, getSecret, getSecrets, getSelectMessages, getServerConfig, getServerConfigs, getTokenPermissions, getUser, getUser as getUser$1, getUserGroups, getUserGroups as getUserGroups$1, getUserOverlayRules, getUserSharingPolicies, getUserSharingPolicy, getUserType, getUserTypes, getUserTypes as getUserTypes$1, getUserUsages, getUsers, getUsers as getUsers$1, getUsersByPath, getUsersMe, getUsersMeMeta, getVariable, getVariables, getVendorPrefix, handleWebAuthnAuthentication, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, hasPermission, hasPermission as hasPermission$1, hasUnresolvedTranslationParams, http, importConfiguration, isApplicationSubmissionValid, isEmojiUri, isEmpty, loadUntilOptionsGrow, mapCredentialUpdateError, mergeOptionsBatch, navigate, navigate as navigate$1, normalizeBorderRadius, normalizeSelectOptions, normalizeTranslations, parseKeyValuePairs, parseKeyValuePairs as parseKeyValuePairs$1, parseRedirectUris, previewCimdDocument, regenerateAgentSecret, regenerateClientSecret, regenerateClientSecret as regenerateClientSecret$1, regenerateFlowSecret, removeGroupMembers, removeGroupMembers as removeGroupMembers$1, removeRoleAssignments, removeRoleAssignments as removeRoleAssignments$1, resolveAdministrationFlowHandles, resolveAdministrationFlowId, resolveAdministrationFlows, resolveAdministrationFlows as resolveAdministrationFlows$1, resolveChangeCredentialPolicy, resolveDesign, resolveFlowTemplateLiterals, resolveLogoUri, resolveManagedIdentityName, resolvePageSize, resolveRequestBaseUrl, resolveResourceEndpoint, resolveTranslation, resolveTranslations, restoreFlowVersion, revertGatewayConfiguration, runAccountLifecycleAction, runAccountLifecycleAction as runAccountLifecycleAction$1, runAdministrationFlow, setTranslation, setTranslations, startCase, substituteTranslationParams, supportsCredential, suspendAgent, suspendApplication, suspendUser, toAuthFlowSelectPage, toCreateApplicationRequest, toEqualityFilter, toError, toManagementErrorMessage, toUpdateApplicationRequest, toUserSelectPage, toUserTypeSelectPage, unlockAgent, unlockUser, unsuspendAgent, unsuspendApplication, unsuspendUser, updateAction, updateAgent, updateAgentType, updateApplication, updateApplication as updateApplication$1, updateApplicationSharingPolicy, updateConnection, updateDesignTheme, updateFlow, updateGateway, updateGatewaySecret, updateGatewayVariable, updateGroup, updateLayout, updateMeCredentials, updateMeProfile, updateNotificationTemplate, updateOrganizationUnit, updateOrganizationUnitByPath, updateResource, updateResourceServer, updateRole, updateSecret, updateServerConfig, updateUser, updateUser as updateUser$1, updateUserCredentials, updateUserSharingPolicy, updateUserType, updateVariable, withVendorCSSClassPrefix } from "@thunderid/browser";
1
+ import { ADMINISTRATION_FLOW_TYPE, APPLICATION_GRANT_TYPES, AccountLifecycleFlowConfigKey, AccountLifecycleFlowConfigKey as AccountLifecycleFlowConfigKey$1, AdministrationFlowConfigKey, AdministrationFlowData, AdministrationFlowError, AdministrationFlowInput, AdministrationModes, AgentQueryKeys, AgentQueryKeys as AgentQueryKeys$1, ApplicationQueryKeys, ApplicationQueryKeys as ApplicationQueryKeys$1, AuthFlowSelectConstants, ConsentConstants, CredentialConstants, DEFAULT_APPLICATION_GRANT_TYPES, DEFAULT_THEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowEventType, EmbeddedFlowEventType as EmbeddedFlowEventType$1, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowType, EmbeddedSignInFlowType as EmbeddedSignInFlowType$1, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatus$1, EmbeddedSignUpFlowType, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, GroupQueryKeys, GroupQueryKeys as GroupQueryKeys$1, RoleQueryKeys, RoleQueryKeys as RoleQueryKeys$1, SPAUtils, SelectConstants, ThunderIDAPIError, ThunderIDAPIError as ThunderIDAPIError$1, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, ThunderIDWordmark, TranslationBundleConstants, UserQueryKeys, UserQueryKeys as UserQueryKeys$1, UserSelectConstants, UserTypeSelectConstants, addGroupMembers, addGroupMembers as addGroupMembers$1, addRoleAssignments, addRoleAssignments as addRoleAssignments$1, applyGatewayConfiguration, arrayBufferToBase64url, base64urlToArrayBuffer, bem, compileConsentDecisions, copyTextToClipboard, createAction, createAgent, createAgent as createAgent$1, createAgentType, createApplication, createApplication as createApplication$1, createApplicationSharingPolicy, createClassObserver, createClassObserver as createClassObserver$1, createConfigurationVersion, createConnection, createDesignTheme, createFlow, createGateway, createGatewaySecret, createGatewayVariable, createGroup, createGroup as createGroup$1, createHttpClientFetcher, createLayout, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createNotificationTemplate, createOrganizationUnit, createPackageComponentLogger, createPackageLogger, createResource, createResourceInvalidator, createResourceInvalidator as createResourceInvalidator$1, createResourceOptionsLoader, createResourceServer, createRole, createRole as createRole$1, createSecret, createTheme, createUser, createUser as createUser$1, createUserByPath, createUserSharingPolicy, createUserType, createVariable, deepMerge, deleteAction, deleteAgent, deleteAgent as deleteAgent$1, deleteAgentType, deleteApplication, deleteApplication as deleteApplication$1, deleteApplicationSharingPolicy, deleteConnection, deleteDesignTheme, deleteFlow, deleteGateway, deleteGatewaySecret, deleteGatewayVariable, deleteGroup, deleteImportedConfiguration, deleteLayout, deleteNotificationTemplate, deleteOrganizationUnit, deleteOrganizationUnitByPath, deleteResource, deleteResourceServer, deleteRole, deleteSecret, deleteTranslation, deleteTranslations, deleteUser, deleteUser as deleteUser$1, deleteUserSharingPolicy, deleteUserType, deleteVariable, detectThemeMode, detectThemeMode as detectThemeMode$1, evaluateChangePasswordForm, executeAdministrationFlow, executeEmbeddedDeviceGrantFlow, executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow, exportConfiguration, extractEmojiFromUri, extractUserClaimsFromIdToken, fallbackResourceInvalidator, findAdministrationFlows, generateFlattenedUserProfile, get, getAccountLifecycleActions, getAccountLifecycleActions as getAccountLifecycleActions$1, getAction, getActions, getActiveTheme, getAgent, getAgent as getAgent$1, getAgentGroups, getAgentGroups as getAgentGroups$1, getAgentName, getAgentName as getAgentName$1, getAgentRoles, getAgentRoles as getAgentRoles$1, getAgentType, getAgentTypes, getAgentTypes as getAgentTypes$1, getAgents, getAgents as getAgents$1, getApplication, getApplication as getApplication$1, getApplicationClientSecret, getApplicationOAuthConfig, getApplicationOverlayRules, getApplicationSharingPolicies, getApplicationSharingPolicy, getApplications, getApplications as getApplications$1, getConfigurationVersion, getConfigurationVersions, getConnection, getConnectionUsages, getConnections, getConnectionsMeta, getConsentElementDecision, getDefaultI18nBundles, getDesignTheme, getDesignThemeUsages, getDesignThemes, getFlow, getFlowMeta, getFlowUsages, getFlowVersion, getFlowVersions, getFlows, getFlows as getFlows$1, getGateway, getGatewayAppliedConfiguration, getGatewayAppliedVersion, getGatewayConfigurationDiff, getGatewaySecret, getGatewaySecrets, getGatewayVariable, getGatewayVariables, getGateways, getGroup, getGroupMembers, getGroupMembers as getGroupMembers$1, getGroups, getGroups as getGroups$1, getLanguages, getLayout, getLayoutUsages, getLayouts, getNotificationTemplate, getNotificationTemplates, getOrganizationUnit, getOrganizationUnitByPath, getOrganizationUnitChildren, getOrganizationUnitGroups, getOrganizationUnitRoles, getOrganizationUnitUsers, getOrganizationUnits, getResource, getResourceServer, getResourceServers, getResources, getRole, getRole as getRole$1, getRoleAssignments, getRoleAssignments as getRoleAssignments$1, getRoles, getRoles as getRoles$1, getSecret, getSecrets, getSelectMessages, getServerConfig, getServerConfigs, getTokenPermissions, getUser, getUser as getUser$1, getUserGroups, getUserGroups as getUserGroups$1, getUserOverlayRules, getUserSharingPolicies, getUserSharingPolicy, getUserType, getUserTypes, getUserTypes as getUserTypes$1, getUserUsages, getUsers, getUsers as getUsers$1, getUsersByPath, getUsersMe, getUsersMeMeta, getVariable, getVariables, getVendorPrefix, handleWebAuthnAuthentication, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, hasPermission, hasPermission as hasPermission$1, hasUnresolvedTranslationParams, http, importConfiguration, isApplicationSubmissionValid, isEmojiUri, isEmpty, loadUntilOptionsGrow, mapCredentialUpdateError, mergeOptionsBatch, navigate, navigate as navigate$1, normalizeBorderRadius, normalizeSelectOptions, normalizeTranslations, parseKeyValuePairs, parseKeyValuePairs as parseKeyValuePairs$1, parseRedirectUris, previewCimdDocument, regenerateAgentSecret, regenerateClientSecret, regenerateClientSecret as regenerateClientSecret$1, regenerateFlowSecret, removeGroupMembers, removeGroupMembers as removeGroupMembers$1, removeRoleAssignments, removeRoleAssignments as removeRoleAssignments$1, resolveAdministrationFlowHandles, resolveAdministrationFlowId, resolveAdministrationFlows, resolveAdministrationFlows as resolveAdministrationFlows$1, resolveChangeCredentialPolicy, resolveDesign, resolveFlowTemplateLiterals, resolveLogoUri, resolveManagedIdentityName, resolvePageSize, resolveRequestBaseUrl, resolveResourceEndpoint, resolveTranslation, resolveTranslations, restoreFlowVersion, revertGatewayConfiguration, runAccountLifecycleAction, runAccountLifecycleAction as runAccountLifecycleAction$1, runAdministrationFlow, setTranslation, setTranslations, startCase, substituteTranslationParams, supportsCredential, suspendAgent, suspendApplication, suspendUser, toAuthFlowSelectPage, toCreateApplicationRequest, toEqualityFilter, toError, toManagementErrorMessage, toUpdateApplicationRequest, toUserSelectPage, toUserTypeSelectPage, unlockAgent, unlockUser, unsuspendAgent, unsuspendApplication, unsuspendUser, updateAction, updateAgent, updateAgentType, updateApplication, updateApplication as updateApplication$1, updateApplicationSharingPolicy, updateConnection, updateDesignTheme, updateFlow, updateGateway, updateGatewaySecret, updateGatewayVariable, updateGroup, updateLayout, updateMeCredentials, updateMeProfile, updateNotificationTemplate, updateOrganizationUnit, updateOrganizationUnitByPath, updateResource, updateResourceServer, updateRole, updateSecret, updateServerConfig, updateUser, updateUser as updateUser$1, updateUserCredentials, updateUserSharingPolicy, updateUserType, updateVariable, withVendorCSSClassPrefix } from "@thunderid/browser";
2
2
  import { Comment, Fragment, Teleport, computed, defineComponent, getCurrentInstance, getCurrentScope, h, inject, nextTick, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, provide, readonly, ref, shallowReadonly, shallowRef, toValue, useId, watch } from "vue";
3
3
  import DOMPurify from "dompurify";
4
4
 
@@ -8618,6 +8618,7 @@ const BaseSignIn = defineComponent({
8618
8618
  const isLoading = computed(() => props.isLoading || isSubmitting.value);
8619
8619
  const formValues = ref({});
8620
8620
  const touchedFields = ref({});
8621
+ const serverFormErrors = ref({});
8621
8622
  watch(() => props.components, (newComponents) => {
8622
8623
  const fields = extractFormFields$1(newComponents || []);
8623
8624
  const freshValues = { ...props.initialValues };
@@ -8626,6 +8627,7 @@ const BaseSignIn = defineComponent({
8626
8627
  });
8627
8628
  formValues.value = freshValues;
8628
8629
  touchedFields.value = {};
8630
+ serverFormErrors.value = {};
8629
8631
  }, {
8630
8632
  deep: false,
8631
8633
  immediate: true
@@ -8636,12 +8638,24 @@ const BaseSignIn = defineComponent({
8636
8638
  ...initialValues
8637
8639
  };
8638
8640
  }, { deep: true });
8639
- const formErrors = computed(() => {
8640
- const fields = extractFormFields$1(props.components || []);
8641
+ watch(() => props.serverFieldErrors, (fieldErrors) => {
8641
8642
  const errors = {};
8642
- (props.serverFieldErrors ?? []).forEach((fieldError) => {
8643
- if (!(fieldError.identifier in errors)) errors[fieldError.identifier] = fieldError.message;
8643
+ const touched = {};
8644
+ (fieldErrors ?? []).forEach((fieldError) => {
8645
+ if (!(fieldError.identifier in errors)) {
8646
+ errors[fieldError.identifier] = fieldError.message;
8647
+ touched[fieldError.identifier] = true;
8648
+ }
8644
8649
  });
8650
+ serverFormErrors.value = errors;
8651
+ if (Object.keys(touched).length > 0) touchedFields.value = {
8652
+ ...touchedFields.value,
8653
+ ...touched
8654
+ };
8655
+ }, { immediate: true });
8656
+ const formErrors = computed(() => {
8657
+ const fields = extractFormFields$1(props.components || []);
8658
+ const errors = { ...serverFormErrors.value };
8645
8659
  fields.forEach((field) => {
8646
8660
  const value = formValues.value[field.name] || "";
8647
8661
  const isTouched = touchedFields.value[field.name] || false;
@@ -8665,6 +8679,11 @@ const BaseSignIn = defineComponent({
8665
8679
  ...formValues.value,
8666
8680
  [name]: value
8667
8681
  };
8682
+ if (name in serverFormErrors.value) {
8683
+ const errors = { ...serverFormErrors.value };
8684
+ delete errors[name];
8685
+ serverFormErrors.value = errors;
8686
+ }
8668
8687
  };
8669
8688
  const handleInputBlur = (name) => {
8670
8689
  touchedFields.value = {
@@ -9085,39 +9104,24 @@ const SignIn = defineComponent({
9085
9104
  const handleSubmit = async (payload) => {
9086
9105
  const effectiveExecutionId = payload.executionId || currentExecutionId.value;
9087
9106
  if (!effectiveExecutionId) throw new Error("No active flow ID");
9088
- const processedInputs = { ...payload.inputs };
9107
+ let processedInputs = { ...payload.inputs };
9089
9108
  if (additionalData.value?.["consentPrompt"]) try {
9090
9109
  const consentRaw = additionalData.value["consentPrompt"];
9091
9110
  const purposes = typeof consentRaw === "string" ? JSON.parse(consentRaw) : consentRaw.purposes || consentRaw;
9092
9111
  let isDeny = false;
9093
9112
  if (payload.action) {
9094
- const findAction = (comps) => {
9113
+ const findAction$1 = (comps) => {
9095
9114
  if (!comps?.length) return null;
9096
9115
  const found = comps.find((c) => c.id === payload.action);
9097
9116
  if (found) return found;
9098
- return comps.reduce((acc, c) => acc || (c.components ? findAction(c.components) : null), null);
9117
+ return comps.reduce((acc, c) => acc || (c.components ? findAction$1(c.components) : null), null);
9099
9118
  };
9100
- const submitAction = findAction(components.value);
9119
+ const submitAction = findAction$1(components.value);
9101
9120
  if (submitAction && submitAction.variant?.toLowerCase() !== "primary") isDeny = true;
9102
9121
  }
9103
- const decisions = {
9122
+ processedInputs = compileConsentDecisions(processedInputs, purposes, {
9104
9123
  approved: !isDeny,
9105
- ...isDeny ? { reason: ConsentConstants.REASON_USER_DENIED } : {},
9106
- purposes: purposes.map((p) => ({
9107
- approved: !isDeny,
9108
- elements: [...(p.essential ?? []).map((e) => ({
9109
- approved: !isDeny,
9110
- name: e.name
9111
- })), ...(p.optional ?? []).map((e) => {
9112
- const key = getConsentOptionalKey(p.purposeId, e.name);
9113
- return getConsentElementDecision(p.purposeId, e, !isDeny && processedInputs[key] === "true", processedInputs);
9114
- })],
9115
- purposeName: p.purposeName
9116
- }))
9117
- };
9118
- processedInputs["consent_decisions"] = JSON.stringify(decisions);
9119
- Object.keys(processedInputs).forEach((key) => {
9120
- if (key.startsWith("__consent_opt__") || key.startsWith(CONSENT_MODIFIED_KEY_PREFIX) || key.startsWith(CONSENT_INVALID_KEY_PREFIX)) delete processedInputs[key];
9124
+ ...isDeny ? { reason: ConsentConstants.REASON_USER_DENIED } : {}
9121
9125
  });
9122
9126
  } catch {}
9123
9127
  try {
@@ -9391,6 +9395,10 @@ const BaseDeviceGrant = defineComponent({
9391
9395
  default: false,
9392
9396
  type: Boolean
9393
9397
  },
9398
+ isTimeoutDisabled: {
9399
+ default: false,
9400
+ type: Boolean
9401
+ },
9394
9402
  error: {
9395
9403
  default: null,
9396
9404
  type: Object
@@ -9447,6 +9455,7 @@ const BaseDeviceGrant = defineComponent({
9447
9455
  error: props.error,
9448
9456
  initialValues: props.initialValues,
9449
9457
  isLoading: props.isLoading,
9458
+ isTimeoutDisabled: props.isTimeoutDisabled,
9450
9459
  onSubmit: props.onSubmit,
9451
9460
  serverFieldErrors: props.serverFieldErrors,
9452
9461
  size: props.size,
@@ -9462,7 +9471,51 @@ var BaseDeviceGrant_default = BaseDeviceGrant;
9462
9471
 
9463
9472
  //#endregion
9464
9473
  //#region src/components/auth/device-grant/DeviceGrant.ts
9474
+ const toDeviceGrantError = (cause, fallbackMessage) => {
9475
+ if (cause instanceof ThunderIDAPIError$1 || cause instanceof ThunderIDRuntimeError$1) return cause;
9476
+ return new ThunderIDRuntimeError$1(cause instanceof Error ? cause.message : fallbackMessage, "DEVICE_GRANT_ERROR", "vue", cause);
9477
+ };
9465
9478
  const hasUserCodeInput = (components) => components.some((component) => component.ref === "user_code" || Array.isArray(component.components) && hasUserCodeInput(component.components));
9479
+ const findAction = (components, actionId) => {
9480
+ for (const component of components) {
9481
+ if (component.id === actionId) return component;
9482
+ if (component.components) {
9483
+ const nestedAction = findAction(component.components, actionId);
9484
+ if (nestedAction) return nestedAction;
9485
+ }
9486
+ }
9487
+ };
9488
+ const parseConsentPurposes = (value) => {
9489
+ let parsed = value;
9490
+ if (typeof parsed === "string") try {
9491
+ parsed = JSON.parse(parsed);
9492
+ } catch {
9493
+ return null;
9494
+ }
9495
+ if (Array.isArray(parsed)) return parsed;
9496
+ if (typeof parsed === "object" && parsed !== null && "purposes" in parsed && Array.isArray(parsed.purposes)) return parsed.purposes;
9497
+ return null;
9498
+ };
9499
+ const CONSENT_REASON_KEY = "__consent_reason__";
9500
+ const flattenComponents = (items) => items.flatMap((component) => [component, ...flattenComponents(component.components ?? [])]);
9501
+ const findConsentSubmitActionId = (items) => {
9502
+ const actions = flattenComponents(items).filter((component) => component.id && component.eventType?.toUpperCase() === "SUBMIT");
9503
+ return (actions.find((component) => component.variant?.toLowerCase() !== "primary") ?? actions[0])?.id;
9504
+ };
9505
+ const compileConsentInputs = (inputs, actionId, components, additionalData) => {
9506
+ const action = actionId ? findAction(components, actionId) : void 0;
9507
+ const purposes = parseConsentPurposes(additionalData["consentPrompt"]);
9508
+ const consentReason = inputs[CONSENT_REASON_KEY];
9509
+ const cleanInputs = { ...inputs };
9510
+ delete cleanInputs[CONSENT_REASON_KEY];
9511
+ const isSubmitAction = Boolean(action && action.eventType?.toUpperCase() !== "TRIGGER");
9512
+ const isTimeout = consentReason === ConsentConstants.REASON_TIMEOUT;
9513
+ const isDeny = isTimeout || Boolean(action && isSubmitAction && action.variant?.toLowerCase() !== "primary");
9514
+ return compileConsentDecisions(cleanInputs, isSubmitAction ? purposes : null, {
9515
+ approved: !isDeny,
9516
+ ...isTimeout ? { reason: ConsentConstants.REASON_TIMEOUT } : isDeny ? { reason: ConsentConstants.REASON_USER_DENIED } : {}
9517
+ });
9518
+ };
9466
9519
  /** Runs the application's configured Device Grant flow and exposes its state for custom renderers. */
9467
9520
  const DeviceGrant = defineComponent({
9468
9521
  name: "DeviceGrant",
@@ -9478,19 +9531,11 @@ const DeviceGrant = defineComponent({
9478
9531
  variant: {
9479
9532
  default: "flat",
9480
9533
  type: String
9481
- },
9482
- onComplete: {
9483
- default: void 0,
9484
- type: Function
9485
- },
9486
- onError: {
9487
- default: void 0,
9488
- type: Function
9489
9534
  }
9490
9535
  },
9491
9536
  emits: ["complete", "error"],
9492
9537
  setup(props, { emit, slots }) {
9493
- const { applicationId, baseUrl } = useThunderID_default();
9538
+ const { applicationId, baseUrl, getStorageManager, isInitialized, isLoading: sdkLoading, vendor } = useThunderID_default();
9494
9539
  const { meta } = useFlowMeta_default();
9495
9540
  const { t } = useI18n_default();
9496
9541
  const components = ref([]);
@@ -9499,28 +9544,61 @@ const DeviceGrant = defineComponent({
9499
9544
  const serverFieldErrors = ref(null);
9500
9545
  const executionId = ref("");
9501
9546
  const challengeToken = ref("");
9547
+ const challengeTokenRef = { current: "" };
9548
+ const isStorageReady = ref(false);
9502
9549
  const error = ref(null);
9503
9550
  const isLoading = ref(false);
9551
+ const isTimeoutDisabled = ref(false);
9504
9552
  const result = ref(null);
9505
9553
  const flowStartAttempted = ref(false);
9506
- const applyResponse = (response) => {
9554
+ const executionIdStorageKey = `${vendor}_device_grant_execution_id`;
9555
+ const oauthCodeProcessedFlag = { value: false };
9556
+ const persistExecutionId = (id) => {
9557
+ executionId.value = id ?? "";
9558
+ if (id) sessionStorage.setItem(executionIdStorageKey, id);
9559
+ else sessionStorage.removeItem(executionIdStorageKey);
9560
+ };
9561
+ const persistChallengeToken = async (token) => {
9562
+ challengeTokenRef.current = token ?? "";
9563
+ challengeToken.value = token ?? "";
9564
+ try {
9565
+ const storageManager = getStorageManager?.();
9566
+ if (storageManager) if (token) await storageManager.setTemporaryDataParameter("challengeToken", token);
9567
+ else await storageManager.removeTemporaryDataParameter("challengeToken");
9568
+ } catch {}
9569
+ };
9570
+ const handleError = (flowError) => {
9571
+ components.value = [];
9572
+ additionalData.value = {};
9573
+ serverFieldErrors.value = null;
9574
+ error.value = flowError;
9575
+ result.value = "failure";
9576
+ emit("error", flowError);
9577
+ };
9578
+ const applyResponse = async (response) => {
9579
+ const redirectURL = response.data?.redirectURL ?? response.redirectUrl;
9580
+ if (response.type === EmbeddedSignInFlowType$1.Redirection && typeof redirectURL === "string") {
9581
+ persistExecutionId(response.executionId ?? null);
9582
+ await persistChallengeToken(response.challengeToken ?? null);
9583
+ initiateOAuthRedirect(redirectURL, vendor);
9584
+ return;
9585
+ }
9507
9586
  const normalized = normalizeFlowResponse(response, t, { resolveTranslations: false }, meta.value);
9508
- executionId.value = response.executionId ?? "";
9509
- challengeToken.value = response.challengeToken ?? "";
9587
+ persistExecutionId(response.flowStatus === EmbeddedSignInFlowStatus$1.Incomplete ? response.executionId ?? null : null);
9588
+ await persistChallengeToken(response.flowStatus === EmbeddedSignInFlowStatus$1.Incomplete ? response.challengeToken ?? null : null);
9510
9589
  components.value = normalized.components ?? [];
9511
9590
  additionalData.value = normalized.additionalData ?? {};
9591
+ isTimeoutDisabled.value = false;
9512
9592
  serverFieldErrors.value = response.data?.fieldErrors ?? null;
9513
9593
  error.value = response.error ? new Error(extractErrorMessage(response, t)) : null;
9514
9594
  if (response.flowStatus === EmbeddedSignInFlowStatus$1.Complete) {
9515
9595
  result.value = "success";
9516
- props.onComplete?.(response);
9517
9596
  emit("complete", response);
9518
9597
  return;
9519
9598
  }
9520
9599
  if (response.flowStatus === EmbeddedSignInFlowStatus$1.Error) {
9521
- error.value = new Error(extractErrorMessage(response, t, "deviceGrant.messages.failed"));
9600
+ error.value = new ThunderIDRuntimeError$1(extractErrorMessage(response, t, "deviceGrant.messages.failed"), "DEVICE_GRANT_ERROR", "vue");
9522
9601
  result.value = "failure";
9523
- props.onError?.(error.value);
9524
9602
  emit("error", error.value);
9525
9603
  return;
9526
9604
  }
@@ -9532,29 +9610,36 @@ const DeviceGrant = defineComponent({
9532
9610
  url.searchParams.delete("applicationId");
9533
9611
  window.history.replaceState(window.history.state, "", url.toString());
9534
9612
  };
9535
- const startFlow = async (appId) => {
9613
+ const startFlow = async (appId, resumeId) => {
9536
9614
  isLoading.value = true;
9537
9615
  error.value = null;
9538
9616
  try {
9539
- const response = await executeEmbeddedDeviceGrantFlow({
9540
- baseUrl,
9541
- payload: {
9542
- applicationId: appId,
9543
- flowType: EmbeddedFlowType.DeviceGrant,
9544
- inputs: {}
9617
+ const challengeFromStorage = challengeTokenRef.current;
9618
+ let response;
9619
+ try {
9620
+ response = await executeEmbeddedDeviceGrantFlow({
9621
+ baseUrl,
9622
+ payload: resumeId ? {
9623
+ executionId: resumeId,
9624
+ ...challengeFromStorage ? { challengeToken: challengeFromStorage } : {}
9625
+ } : {
9626
+ applicationId: appId,
9627
+ flowType: EmbeddedFlowType.DeviceGrant,
9628
+ inputs: {}
9629
+ }
9630
+ });
9631
+ } catch (resumeError) {
9632
+ if (resumeId && resumeError instanceof ThunderIDAPIError$1 && resumeError.statusCode === 400) {
9633
+ persistExecutionId(null);
9634
+ await persistChallengeToken(null);
9635
+ throw new ThunderIDRuntimeError$1(t("deviceGrant.errors.continue"), "DEVICE_GRANT_ERROR", "vue");
9545
9636
  }
9546
- });
9547
- clearVerificationParameters();
9548
- applyResponse(response);
9637
+ throw resumeError;
9638
+ }
9639
+ if (!resumeId) clearVerificationParameters();
9640
+ await applyResponse(response);
9549
9641
  } catch (cause) {
9550
- const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9551
- components.value = [];
9552
- additionalData.value = {};
9553
- serverFieldErrors.value = null;
9554
- error.value = flowError;
9555
- result.value = "failure";
9556
- props.onError?.(flowError);
9557
- emit("error", flowError);
9642
+ handleError(toDeviceGrantError(cause, t("deviceGrant.errors.continue")));
9558
9643
  } finally {
9559
9644
  isLoading.value = false;
9560
9645
  }
@@ -9565,48 +9650,121 @@ const DeviceGrant = defineComponent({
9565
9650
  result.value = null;
9566
9651
  try {
9567
9652
  if (!executionId.value) return;
9568
- const inputs = Object.fromEntries(Object.entries(payload.inputs ?? {}).filter(([key]) => !key.startsWith("__consent_opt__")));
9653
+ const action = payload.action ?? actionId;
9654
+ const inputs = compileConsentInputs(payload.inputs ?? {}, action, components.value, additionalData.value);
9569
9655
  if (!hasUserCodeInput(components.value)) delete inputs["user_code"];
9570
- applyResponse(await executeEmbeddedDeviceGrantFlow({
9656
+ await applyResponse(await executeEmbeddedDeviceGrantFlow({
9571
9657
  baseUrl,
9572
9658
  payload: {
9573
- action: payload.action ?? actionId,
9659
+ action,
9574
9660
  challengeToken: challengeToken.value,
9575
9661
  executionId: executionId.value,
9576
9662
  inputs
9577
9663
  }
9578
9664
  }));
9579
9665
  } catch (cause) {
9580
- const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9581
- components.value = [];
9582
- additionalData.value = {};
9583
- serverFieldErrors.value = null;
9584
- error.value = flowError;
9585
- result.value = "failure";
9586
- props.onError?.(flowError);
9587
- emit("error", flowError);
9666
+ handleError(toDeviceGrantError(cause, t("deviceGrant.errors.continue")));
9588
9667
  } finally {
9589
9668
  isLoading.value = false;
9590
9669
  }
9591
9670
  };
9592
- onMounted(() => {
9671
+ let timeoutHandle = null;
9672
+ let timeoutSubmittedFor = null;
9673
+ watch(() => [additionalData.value["stepTimeout"], executionId.value], ([stepTimeout, activeExecutionId]) => {
9674
+ if (timeoutHandle) clearTimeout(timeoutHandle);
9675
+ timeoutHandle = null;
9676
+ const timeoutMs = Number(stepTimeout) || 0;
9677
+ if (timeoutMs <= 0 || !activeExecutionId) {
9678
+ isTimeoutDisabled.value = false;
9679
+ return;
9680
+ }
9681
+ timeoutHandle = setTimeout(() => {
9682
+ isTimeoutDisabled.value = true;
9683
+ const expiredError = new ThunderIDRuntimeError$1(t("errors.signin.timeout") || "Time allowed to complete the step has expired.", "DEVICE_GRANT_ERROR", "vue");
9684
+ const actionId = additionalData.value["consentPrompt"] ? findConsentSubmitActionId(components.value) : void 0;
9685
+ if (actionId && timeoutSubmittedFor !== timeoutMs) {
9686
+ timeoutSubmittedFor = timeoutMs;
9687
+ submit({
9688
+ action: actionId,
9689
+ inputs: { [CONSENT_REASON_KEY]: ConsentConstants.REASON_TIMEOUT }
9690
+ }, actionId);
9691
+ return;
9692
+ }
9693
+ handleError(expiredError);
9694
+ }, Math.max(0, timeoutMs - Date.now()));
9695
+ });
9696
+ onUnmounted(() => {
9697
+ if (timeoutHandle) clearTimeout(timeoutHandle);
9698
+ });
9699
+ const sdkReady = isInitialized ?? ref(true);
9700
+ const sdkIsLoading = sdkLoading ?? ref(false);
9701
+ const callbackReady = computed(() => sdkReady.value && !sdkIsLoading.value && isStorageReady.value);
9702
+ watch(() => [sdkReady.value, sdkIsLoading.value], async ([ready, loading]) => {
9703
+ if (!ready || loading || isStorageReady.value) return;
9704
+ try {
9705
+ const storedChallengeToken = (await getStorageManager?.()?.getTemporaryData())?.["challengeToken"];
9706
+ if (typeof storedChallengeToken === "string") {
9707
+ challengeTokenRef.current = storedChallengeToken;
9708
+ challengeToken.value = storedChallengeToken;
9709
+ }
9710
+ } catch {} finally {
9711
+ isStorageReady.value = true;
9712
+ }
9713
+ }, { immediate: true });
9714
+ useOAuthCallback({
9715
+ currentFlowId: executionId,
9716
+ flowIdStorageKey: executionIdStorageKey,
9717
+ isInitialized: callbackReady,
9718
+ isSubmitting: isLoading,
9719
+ onError: (cause) => {
9720
+ persistExecutionId(null);
9721
+ persistChallengeToken(null);
9722
+ handleError(toDeviceGrantError(cause, String(cause)));
9723
+ },
9724
+ onFlowChange: (response) => void applyResponse(response),
9725
+ onSubmit: async (payload) => {
9726
+ isLoading.value = true;
9727
+ try {
9728
+ return await executeEmbeddedDeviceGrantFlow({
9729
+ baseUrl,
9730
+ payload: {
9731
+ challengeToken: challengeTokenRef.current || challengeToken.value,
9732
+ executionId: payload.flowId,
9733
+ inputs: payload.inputs
9734
+ }
9735
+ });
9736
+ } finally {
9737
+ isLoading.value = false;
9738
+ }
9739
+ },
9740
+ processedFlag: oauthCodeProcessedFlag,
9741
+ setFlowId: persistExecutionId
9742
+ });
9743
+ watch(() => [
9744
+ sdkReady.value,
9745
+ sdkIsLoading.value,
9746
+ isStorageReady.value
9747
+ ], async ([ready, loading, storageReady]) => {
9748
+ if (!ready || loading || !storageReady || flowStartAttempted.value) return;
9593
9749
  const url = new URL(window.location.href);
9594
9750
  const code = url.searchParams.get("user_code");
9595
9751
  if (code) initialValues.value = { user_code: code };
9596
9752
  const applicationIdFromUrl = url.searchParams.get("applicationId");
9597
9753
  const appId = applicationIdFromUrl?.trim() ? applicationIdFromUrl : applicationId;
9598
- if (!appId) {
9599
- const flowError = new Error(t("deviceGrant.errors.start"));
9754
+ if (url.searchParams.has("code") || url.searchParams.has("state") || url.searchParams.has("error") || oauthCodeProcessedFlag.value) return;
9755
+ const storedExecutionId = sessionStorage.getItem(executionIdStorageKey);
9756
+ if (!appId && !storedExecutionId) {
9757
+ flowStartAttempted.value = true;
9758
+ const flowError = new ThunderIDRuntimeError$1(t("deviceGrant.errors.start"), "DEVICE_GRANT_ERROR", "vue");
9600
9759
  error.value = flowError;
9601
9760
  result.value = "failure";
9602
- props.onError?.(flowError);
9603
9761
  emit("error", flowError);
9604
9762
  return;
9605
9763
  }
9606
9764
  if (flowStartAttempted.value) return;
9607
9765
  flowStartAttempted.value = true;
9608
- startFlow(appId);
9609
- });
9766
+ await startFlow(appId ?? "", storedExecutionId ?? void 0);
9767
+ }, { immediate: true });
9610
9768
  return () => h(BaseDeviceGrant_default, {
9611
9769
  className: props.className,
9612
9770
  components: components.value,
@@ -9614,6 +9772,7 @@ const DeviceGrant = defineComponent({
9614
9772
  error: error.value,
9615
9773
  initialValues: initialValues.value,
9616
9774
  isLoading: isLoading.value,
9775
+ isTimeoutDisabled: isTimeoutDisabled.value,
9617
9776
  onSubmit: (payload, component) => submit(payload, component.id),
9618
9777
  result: result.value,
9619
9778
  serverFieldErrors: serverFieldErrors.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thunderid/vue",
3
- "version": "1.10.3",
3
+ "version": "1.11.0",
4
4
  "description": "Vue SDK for ThunderID",
5
5
  "keywords": [
6
6
  "thunderid",
@@ -57,7 +57,7 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "@thunderid/browser": "^1.9.3",
60
+ "@thunderid/browser": "^1.10.0",
61
61
  "dompurify": "3.4.17",
62
62
  "tslib": "2.8.1"
63
63
  },