@mxenabled/connect-widget 2.17.10 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -5269,23 +5269,39 @@ function baseFindIndex$2(array, predicate, fromIndex, fromRight) {
5269
5269
  }
5270
5270
  var _baseFindIndex = baseFindIndex$2;
5271
5271
 
5272
- var reWhitespace = /\s/;
5273
- function trimmedEndIndex$1(string) {
5274
- var index = string.length;
5275
- while (index-- && reWhitespace.test(string.charAt(index))) {
5276
- }
5277
- return index;
5272
+ var _trimmedEndIndex;
5273
+ var hasRequired_trimmedEndIndex;
5274
+
5275
+ function require_trimmedEndIndex () {
5276
+ if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
5277
+ hasRequired_trimmedEndIndex = 1;
5278
+ var reWhitespace = /\s/;
5279
+ function trimmedEndIndex(string) {
5280
+ var index = string.length;
5281
+ while (index-- && reWhitespace.test(string.charAt(index))) {
5282
+ }
5283
+ return index;
5284
+ }
5285
+ _trimmedEndIndex = trimmedEndIndex;
5286
+ return _trimmedEndIndex;
5278
5287
  }
5279
- var _trimmedEndIndex = trimmedEndIndex$1;
5280
5288
 
5281
- var trimmedEndIndex = _trimmedEndIndex;
5282
- var reTrimStart = /^\s+/;
5283
- function baseTrim$1(string) {
5284
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5289
+ var _baseTrim;
5290
+ var hasRequired_baseTrim;
5291
+
5292
+ function require_baseTrim () {
5293
+ if (hasRequired_baseTrim) return _baseTrim;
5294
+ hasRequired_baseTrim = 1;
5295
+ var trimmedEndIndex = require_trimmedEndIndex();
5296
+ var reTrimStart = /^\s+/;
5297
+ function baseTrim(string) {
5298
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5299
+ }
5300
+ _baseTrim = baseTrim;
5301
+ return _baseTrim;
5285
5302
  }
5286
- var _baseTrim = baseTrim$1;
5287
5303
 
5288
- var baseTrim = _baseTrim, isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5304
+ var baseTrim = require_baseTrim(), isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5289
5305
  var NAN = 0 / 0;
5290
5306
  var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
5291
5307
  var reIsBinary = /^0b[01]+$/i;
@@ -8767,7 +8783,7 @@ var hasRequiredTrim;
8767
8783
  function requireTrim () {
8768
8784
  if (hasRequiredTrim) return trim_1;
8769
8785
  hasRequiredTrim = 1;
8770
- var baseToString = _baseToString, baseTrim = _baseTrim, castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8786
+ var baseToString = _baseToString, baseTrim = require_baseTrim(), castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8771
8787
  function trim(string, chars, guard) {
8772
8788
  string = toString(string);
8773
8789
  if (string && (guard || chars === void 0)) {
@@ -9406,7 +9422,8 @@ function institutionIsBlockedForCostReasons(institution) {
9406
9422
 
9407
9423
  const initialState$6 = {
9408
9424
  optOutOfEarlyUserRelease: false,
9409
- unavailableInstitutions: []
9425
+ unavailableInstitutions: [],
9426
+ memberPollingMilliseconds: void 0
9410
9427
  };
9411
9428
  const experimentalFeaturesSlice = createSlice({
9412
9429
  name: "experimentalFeatures",
@@ -9415,6 +9432,7 @@ const experimentalFeaturesSlice = createSlice({
9415
9432
  loadExperimentalFeatures(state, action) {
9416
9433
  state.unavailableInstitutions = action.payload?.unavailableInstitutions || [];
9417
9434
  state.optOutOfEarlyUserRelease = action.payload?.optOutOfEarlyUserRelease || false;
9435
+ state.memberPollingMilliseconds = action.payload?.memberPollingMilliseconds || void 0;
9418
9436
  }
9419
9437
  }
9420
9438
  });
@@ -64039,6 +64057,26 @@ function delay$1(due, scheduler) {
64039
64057
  });
64040
64058
  }
64041
64059
 
64060
+ function exhaustMap(project, resultSelector) {
64061
+ return operate(function(source, subscriber) {
64062
+ var index = 0;
64063
+ var innerSub = null;
64064
+ var isComplete = false;
64065
+ source.subscribe(createOperatorSubscriber(subscriber, function(outerValue) {
64066
+ if (!innerSub) {
64067
+ innerSub = createOperatorSubscriber(subscriber, void 0, function() {
64068
+ innerSub = null;
64069
+ isComplete && subscriber.complete();
64070
+ });
64071
+ innerFrom(project(outerValue, index++)).subscribe(innerSub);
64072
+ }
64073
+ }, function() {
64074
+ isComplete = true;
64075
+ !innerSub && subscriber.complete();
64076
+ }));
64077
+ });
64078
+ }
64079
+
64042
64080
  function pluck() {
64043
64081
  var properties = [];
64044
64082
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -73495,7 +73533,7 @@ const ViewTitle = ({ connectionStatus, title }) => {
73495
73533
  const tokens = useTokens();
73496
73534
  const styles = getStyles$14(tokens);
73497
73535
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: styles.container, children: [
73498
- /* @__PURE__ */ jsxRuntimeExports.jsx(L, { bold: true, component: "h2", "data-test": "title-text", truncate: false, variant: "H2", children: title }),
73536
+ /* @__PURE__ */ jsxRuntimeExports.jsx(L, { bold: true, component: "h1", "data-test": "title-text", truncate: false, variant: "H2", children: title }),
73499
73537
  connectionStatus === ReadableStatuses$1.DEGRADED && /* @__PURE__ */ jsxRuntimeExports.jsx(InfoFilled, { color: tokens.BackgroundColor.MessageBoxHelp, size: 24 }),
73500
73538
  connectionStatus === ReadableStatuses$1.REJECTED && /* @__PURE__ */ jsxRuntimeExports.jsx(AttentionFilled, { color: tokens.BackgroundColor.MessageBoxError, size: 24 })
73501
73539
  ] });
@@ -76168,52 +76206,6 @@ const DEFAULT_POLLING_STATE = {
76168
76206
  initialDataReady: false
76169
76207
  // whether the initial data ready event has been sent
76170
76208
  };
76171
- function pollMember(memberGuid, api, clientLocale, optOutOfEarlyUserRelease = false) {
76172
- return interval(3e3).pipe(
76173
- switchMap(
76174
- () => (
76175
- // Poll the currentMember. Catch errors but don't handle it here
76176
- // the scan will handle it below
76177
- defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
76178
- mergeMap(
76179
- (member) => defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
76180
- map((job) => ({ member, job }))
76181
- )
76182
- ),
76183
- catchError((error) => of(error))
76184
- )
76185
- )
76186
- ),
76187
- scan(
76188
- (acc, response) => {
76189
- const isError = response instanceof Error;
76190
- const pollingState = {
76191
- // only track if the most recent poll was an error
76192
- isError,
76193
- // always increase polling count
76194
- pollingCount: acc.pollingCount + 1,
76195
- // dont update previous response if this is an error
76196
- previousResponse: isError ? acc.previousResponse : acc.currentResponse,
76197
- // dont update current response if this is an error
76198
- currentResponse: isError ? acc.currentResponse : response,
76199
- // preserve the initialDataReadySent flag
76200
- initialDataReady: acc.initialDataReady
76201
- };
76202
- if (!isError && !acc.initialDataReady && response?.job?.async_account_data_ready && !optOutOfEarlyUserRelease) {
76203
- pollingState.initialDataReady = true;
76204
- }
76205
- const [shouldStopPolling, messageKey] = handlePollingResponse(pollingState);
76206
- return {
76207
- ...pollingState,
76208
- // we should keep polling based on the member
76209
- pollingIsDone: isError ? false : shouldStopPolling,
76210
- userMessage: messageKey
76211
- };
76212
- },
76213
- { ...DEFAULT_POLLING_STATE }
76214
- )
76215
- );
76216
- }
76217
76209
  function handlePollingResponse(pollingState) {
76218
76210
  const polledMember = pollingState.currentResponse?.member || {};
76219
76211
  const previousMember = pollingState.previousResponse?.member || {};
@@ -76248,7 +76240,14 @@ function handlePollingResponse(pollingState) {
76248
76240
  }
76249
76241
  function pollOauthState(oauthStateGuid, api) {
76250
76242
  return interval(1e3).pipe(
76251
- switchMap(
76243
+ /**
76244
+ * used to be switchMap
76245
+ * exhaustMap ignores new emissions from the source while the current inner observable is still active.
76246
+ *
76247
+ * This ensures that we do not start a new poll request until the previous one has completed,
76248
+ * preventing overlapping requests and potential race conditions.
76249
+ */
76250
+ exhaustMap(
76252
76251
  () => (
76253
76252
  // Poll the oauthstate. Catch errors but don't handle it here
76254
76253
  // the scan will handle it below
@@ -78721,6 +78720,70 @@ function getReferrer() {
78721
78720
  }
78722
78721
  const isValidUrl = (url) => typeof url === "string" && url.match(/((\w+:\/\/)[-a-zA-Z0-9:@;?&=/%+.*!'(),$_{}^~[\]`#|]+)/g);
78723
78722
 
78723
+ function usePollMember() {
78724
+ const { api } = useApi();
78725
+ const clientLocale = useMemo(() => {
78726
+ return document.querySelector("html")?.getAttribute("lang") || "en";
78727
+ }, [document.querySelector("html")?.getAttribute("lang")]);
78728
+ const { optOutOfEarlyUserRelease, memberPollingMilliseconds } = useSelector(getExperimentalFeatures);
78729
+ const pollingInterval = memberPollingMilliseconds || 3e3;
78730
+ const pollMember = (memberGuid) => {
78731
+ return interval(pollingInterval).pipe(
78732
+ /**
78733
+ * used to be switchMap
78734
+ * exhaustMap ignores new emissions from the source while the current inner observable is still active.
78735
+ *
78736
+ * This ensures that we do not start a new poll request until the previous one has completed,
78737
+ * preventing overlapping requests and potential race conditions.
78738
+ */
78739
+ exhaustMap(
78740
+ () => (
78741
+ // Poll the currentMember. Catch errors but don't handle it here
78742
+ // the scan will handle it below
78743
+ // @ts-expect-error: cannot invoke a method that might be undefined
78744
+ defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
78745
+ mergeMap(
78746
+ (member) => defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
78747
+ map((job) => ({ member, job }))
78748
+ )
78749
+ ),
78750
+ catchError((error) => of(error))
78751
+ )
78752
+ )
78753
+ ),
78754
+ scan(
78755
+ (acc, response) => {
78756
+ const isError = response instanceof Error;
78757
+ const pollingState = {
78758
+ // only track if the most recent poll was an error
78759
+ isError,
78760
+ // always increase polling count
78761
+ pollingCount: acc.pollingCount + 1,
78762
+ // dont update previous response if this is an error
78763
+ previousResponse: isError ? acc.previousResponse : acc.currentResponse,
78764
+ // dont update current response if this is an error
78765
+ currentResponse: isError ? acc.currentResponse : response,
78766
+ // preserve the initialDataReadySent flag
78767
+ initialDataReady: acc.initialDataReady
78768
+ };
78769
+ if (!isError && !acc.initialDataReady && response?.job?.async_account_data_ready && !optOutOfEarlyUserRelease) {
78770
+ pollingState.initialDataReady = true;
78771
+ }
78772
+ const [shouldStopPolling, messageKey] = handlePollingResponse(pollingState);
78773
+ return {
78774
+ ...pollingState,
78775
+ // we should keep polling based on the member
78776
+ pollingIsDone: isError ? false : shouldStopPolling,
78777
+ userMessage: messageKey
78778
+ };
78779
+ },
78780
+ { ...DEFAULT_POLLING_STATE }
78781
+ )
78782
+ );
78783
+ };
78784
+ return pollMember;
78785
+ }
78786
+
78724
78787
  const Connecting = (props) => {
78725
78788
  const {
78726
78789
  connectConfig,
@@ -78731,7 +78794,6 @@ const Connecting = (props) => {
78731
78794
  onUpsertMember
78732
78795
  } = props;
78733
78796
  const selectedInstitution = useSelector(getSelectedInstitution);
78734
- const { optOutOfEarlyUserRelease } = useSelector(getExperimentalFeatures);
78735
78797
  const sendAnalyticsEvent = useAnalyticsEvent();
78736
78798
  const clientLocale = useMemo(() => {
78737
78799
  return document.querySelector("html")?.getAttribute("lang") || "en";
@@ -78753,6 +78815,7 @@ const Connecting = (props) => {
78753
78815
  const [message, setMessage] = useState(CONNECTING_MESSAGES.STARTING);
78754
78816
  const [timedOut, setTimedOut] = useState(false);
78755
78817
  const [connectingError, setConnectingError] = useState(null);
78818
+ const pollMember = usePollMember();
78756
78819
  const activeJob = getActiveJob(jobSchedule);
78757
78820
  const needsToInitializeJobSchedule = jobSchedule.isInitialized === false;
78758
78821
  function handleMemberPoll(pollingState) {
@@ -78882,7 +78945,7 @@ const Connecting = (props) => {
78882
78945
  return needsJobStarted ? startJob$ : of(currentMember);
78883
78946
  }).pipe(
78884
78947
  concatMap(
78885
- (member) => pollMember(member.guid, api, clientLocale, optOutOfEarlyUserRelease).pipe(
78948
+ (member) => pollMember(member.guid).pipe(
78886
78949
  tap((pollingState) => handleMemberPoll(pollingState)),
78887
78950
  filter((pollingState) => pollingState.pollingIsDone),
78888
78951
  pluck("currentResponse"),
@@ -81307,7 +81370,7 @@ const RoutingNumber = (props) => {
81307
81370
  /* @__PURE__ */ jsxRuntimeExports.jsx(SlideDown, { delay: getNextDelay(), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: styles.header, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
81308
81371
  L,
81309
81372
  {
81310
- component: "h2",
81373
+ component: "h1",
81311
81374
  "data-test": "microdeposit-header",
81312
81375
  style: styles.title,
81313
81376
  truncate: false,