@mxenabled/connect-widget 0.0.4 → 0.0.5

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
@@ -5130,39 +5130,23 @@ function baseFindIndex$2(array, predicate, fromIndex, fromRight) {
5130
5130
  }
5131
5131
  var _baseFindIndex = baseFindIndex$2;
5132
5132
 
5133
- var _trimmedEndIndex;
5134
- var hasRequired_trimmedEndIndex;
5135
-
5136
- function require_trimmedEndIndex () {
5137
- if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
5138
- hasRequired_trimmedEndIndex = 1;
5139
- var reWhitespace = /\s/;
5140
- function trimmedEndIndex(string) {
5141
- var index = string.length;
5142
- while (index-- && reWhitespace.test(string.charAt(index))) {
5143
- }
5144
- return index;
5145
- }
5146
- _trimmedEndIndex = trimmedEndIndex;
5147
- return _trimmedEndIndex;
5133
+ var reWhitespace = /\s/;
5134
+ function trimmedEndIndex$1(string) {
5135
+ var index = string.length;
5136
+ while (index-- && reWhitespace.test(string.charAt(index))) {
5137
+ }
5138
+ return index;
5148
5139
  }
5140
+ var _trimmedEndIndex = trimmedEndIndex$1;
5149
5141
 
5150
- var _baseTrim;
5151
- var hasRequired_baseTrim;
5152
-
5153
- function require_baseTrim () {
5154
- if (hasRequired_baseTrim) return _baseTrim;
5155
- hasRequired_baseTrim = 1;
5156
- var trimmedEndIndex = require_trimmedEndIndex();
5157
- var reTrimStart = /^\s+/;
5158
- function baseTrim(string) {
5159
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5160
- }
5161
- _baseTrim = baseTrim;
5162
- return _baseTrim;
5142
+ var trimmedEndIndex = _trimmedEndIndex;
5143
+ var reTrimStart = /^\s+/;
5144
+ function baseTrim$1(string) {
5145
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5163
5146
  }
5147
+ var _baseTrim = baseTrim$1;
5164
5148
 
5165
- var baseTrim = require_baseTrim(), isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5149
+ var baseTrim = _baseTrim, isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5166
5150
  var NAN = 0 / 0;
5167
5151
  var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
5168
5152
  var reIsBinary = /^0b[01]+$/i;
@@ -8628,7 +8612,7 @@ var hasRequiredTrim;
8628
8612
  function requireTrim () {
8629
8613
  if (hasRequiredTrim) return trim_1;
8630
8614
  hasRequiredTrim = 1;
8631
- var baseToString = _baseToString, baseTrim = require_baseTrim(), castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8615
+ var baseToString = _baseToString, baseTrim = _baseTrim, castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8632
8616
  function trim(string, chars, guard) {
8633
8617
  string = toString(string);
8634
8618
  if (string && (guard || chars === void 0)) {
@@ -9566,7 +9550,8 @@ const initialState$5 = {
9566
9550
  oauth_referral_source: REFERRAL_SOURCES.BROWSER,
9567
9551
  update_credentials: false,
9568
9552
  wait_for_full_aggregation: false,
9569
- data_request: null
9553
+ data_request: null,
9554
+ use_cases: null
9570
9555
  };
9571
9556
  const configSlice = createSlice({
9572
9557
  name: "config",
@@ -9603,7 +9588,8 @@ const selectConnectConfig = createSelector(selectConfig, (config) => ({
9603
9588
  oauth_referral_source: config.oauth_referral_source,
9604
9589
  update_credentials: config.update_credentials,
9605
9590
  wait_for_full_aggregation: config.wait_for_full_aggregation,
9606
- data_request: config.data_request
9591
+ data_request: config.data_request,
9592
+ use_cases: config.use_cases
9607
9593
  }));
9608
9594
  const selectColorScheme = (state) => state.config.color_scheme;
9609
9595
  const getProductDeterminedMode = (config) => {
@@ -13925,25 +13911,18 @@ if (typeof window !== "undefined") {
13925
13911
  }
13926
13912
 
13927
13913
  const getExperiments = (state) => state.experiments.items;
13928
- const getActiveExperiments = createSelector(
13929
- getExperiments,
13930
- (experiments) => experiments.filter((experiment) => experiment.is_active)
13931
- );
13932
- const getExperimentNamesToUserVariantMap = createSelector(
13933
- getActiveExperiments,
13934
- (experiments) => {
13935
- return experiments.reduce((acc, experiment) => {
13936
- if (experiment.selected_variant) {
13937
- const selectedVariantFeatureGuid = experiment.selected_variant.user_feature.feature_guid;
13938
- const feature = experiment.features.find(
13939
- (feature2) => feature2.guid === selectedVariantFeatureGuid
13940
- );
13941
- return { ...acc, [experiment.name]: feature.name };
13942
- }
13943
- return acc;
13944
- }, {});
13945
- }
13946
- );
13914
+ const getExperimentNamesToUserVariantMap = createSelector(getExperiments, (experiments) => {
13915
+ return experiments.reduce((acc, experiment) => {
13916
+ if (experiment.is_active && experiment.selected_variant) {
13917
+ const selectedVariantFeatureGuid = experiment.selected_variant.user_feature.feature_guid;
13918
+ const feature = experiment.features.find(
13919
+ (feature2) => feature2.guid === selectedVariantFeatureGuid
13920
+ );
13921
+ return { ...acc, [experiment.name]: feature.name };
13922
+ }
13923
+ return acc;
13924
+ }, {});
13925
+ });
13947
13926
 
13948
13927
  var dist = {};
13949
13928
 
@@ -14834,10 +14813,7 @@ const AnalyticEvents = {
14834
14813
  MFA_SUBMITTED_IMAGE: "mfa_submitted_image",
14835
14814
  MFA_SELECTED_OPTION: "mfa_selected_option",
14836
14815
  MFA_SUBMITTED_OPTION: "mfa_submitted_option",
14837
- MONEY_MANAGER_POPUP: "money_manager_popup",
14838
- MONEY_MANAGER_POPUP_CLOSED: "money_manager_popup_closed",
14839
14816
  NO_ELIGIBLE_ACCOUNTS_RETRY: "no_eligible_accounts_retry",
14840
- NO_ELIGIBLE_ACCOUNTS_TRY_ANOTHER_INSTITUTION: "no_eligible_accounts_try_another_institution",
14841
14817
  OAUTH_PENDING_MEMBER_CREATED: "oauth_pending_member_created",
14842
14818
  OAUTH_DEFAULT_CANCEL: "oauth_default_cancel",
14843
14819
  OAUTH_DEFAULT_GO_TO_INSTITUTION: "oauth_default_go_to_institution",
@@ -14869,14 +14845,12 @@ const PageviewInfo = {
14869
14845
  CONNECT_DISCLOSURE_DATA_AVAILABLE: ["Connect Disclosure Data Available", "/data_available"],
14870
14846
  CONNECT_DISCLOSURE_DATA_REQUESTED: ["Connect Disclosure Data Requested", "/data_requested"],
14871
14847
  CONNECT_DISCLOSURE_PRIVACY_POLICY: ["Connect Disclosure Privacy Policy", "/privacy_policy"],
14872
- CONNECT_EXISTING_MEMBER_WARNING: ["Connect Existing Member Warning", "/existing_member_warning"],
14873
14848
  CONNECT_GENERIC_ERROR: ["Connect Generic Error", "/generic_error"],
14874
14849
  CONNECT_IE_11_DEPRECATION: ["Connect IE 11 Deprecation", "/ie_11_deprecation"],
14875
14850
  CONNECT_LOGIN_ERROR: ["Connect Login Error", "/login_error"],
14876
14851
  CONNECT_MANUAL_ACCOUNT: ["Manual Account Connect", "/manual_account_connect"],
14877
14852
  CONNECT_MANUAL_ACCOUNT_FORM: ["Connect Manual Account Form", "/manual_account_form"],
14878
14853
  CONNECT_MANUAL_ACCOUNT_SUCCESS: ["Connect Manual Account Success", "/manual_account_success"],
14879
- CONNECT_MFA: ["Connect MFA", "/mfa"],
14880
14854
  CONNECT_MFA_DEFAULT: ["Connect MFA Default", "/mfa_default"],
14881
14855
  CONNECT_MFA_IMAGE_OPTIONS: ["Connect MFA Image Options", "/mfa_image_options"],
14882
14856
  CONNECT_MFA_OPTIONS: ["Connect MFA Options", "/mfa_options"],
@@ -14928,15 +14902,12 @@ const PageviewInfo = {
14928
14902
  ],
14929
14903
  CONNECT_SUPPORT_GENERAL: ["Connect Support General", "/support/support_general"],
14930
14904
  CONNECT_SUPPORT_SUCCESS: ["Connect Support Success", "/support/support_success"],
14931
- CONNECT_SURVEY_FEEDBACK: ["Connect Survey Feedback", "/survey/feedback"],
14932
- CONNECT_TIMEOUT: ["Connect Timeout", "/timeout"],
14933
14905
  CONNECT_UPDATE_CREDENTIALS: [
14934
14906
  "Connect Update Credentials",
14935
14907
  "/credentials/update_credentials_form"
14936
14908
  ],
14937
14909
  CONNECT_UNSUPPORTED_RESOLUTION: ["Connect Unsupported Resolution", "/unsupported_resolution"],
14938
- CONNECT_VERIFY_EXISTING_MEMBER: ["Connect Verify Existing Member", "/verify_existing_member"],
14939
- CONNECTIONS: ["Connections", "/connections"]
14910
+ CONNECT_VERIFY_EXISTING_MEMBER: ["Connect Verify Existing Member", "/verify_existing_member"]
14940
14911
  };
14941
14912
  const AuthenticationMethods = {
14942
14913
  OAUTH: "OAuth",
@@ -21391,8 +21362,7 @@ var intervalProvider = {
21391
21362
  return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
21392
21363
  },
21393
21364
  clearInterval: function(handle) {
21394
- var delegate = intervalProvider.delegate;
21395
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
21365
+ return (clearInterval)(handle);
21396
21366
  },
21397
21367
  delegate: void 0
21398
21368
  };
@@ -36062,6 +36032,7 @@ const CreateMemberForm = (props) => {
36062
36032
  });
36063
36033
  const config = useSelector(selectConfig);
36064
36034
  const isHuman = useSelector((state2) => state2.app.humanEvent);
36035
+ const currentMembers = useSelector((state2) => state2.connect.members);
36065
36036
  const [isCreatingMember, setIsCreatingMember] = useState(false);
36066
36037
  const [memberCreateError, setMemberCreateError] = useState(null);
36067
36038
  const [userCredentials, setUserCredentials] = useState(null);
@@ -36117,9 +36088,19 @@ const CreateMemberForm = (props) => {
36117
36088
  payload: member.guid
36118
36089
  }))
36119
36090
  );
36120
- const updateMember$ = defer(
36121
- () => api.updateMember({ ...memberData, guid: memberGuid })
36122
- ).pipe(
36091
+ const updateMember$ = defer(() => {
36092
+ const current409member = currentMembers.find((mbr) => mbr.guid === memberGuid);
36093
+ if (!current409member) {
36094
+ setIsCreatingMember(false);
36095
+ setMemberCreateError("Something went wrong, invalid member state");
36096
+ return new Error("Something went wrong, invalid member state");
36097
+ }
36098
+ const oldUseCases = current409member.use_cases || null;
36099
+ return api.updateMember(
36100
+ { ...memberData, guid: memberGuid, use_cases: oldUseCases },
36101
+ config
36102
+ );
36103
+ }).pipe(
36123
36104
  map((member) => {
36124
36105
  if (props.onUpsertMember) {
36125
36106
  props.onUpsertMember(member);
@@ -36497,6 +36478,7 @@ const Connecting$2 = (props) => {
36497
36478
  } = props;
36498
36479
  const currentMember = useSelector((state) => getCurrentMember(state));
36499
36480
  const isComboJobsEnabled = useSelector((state) => isConnectComboJobsEnabled(state));
36481
+ const jobSchedule = useSelector((state) => state.connect.jobSchedule);
36500
36482
  useAnalyticsPath(...PageviewInfo.CONNECT_CONNECTING, {
36501
36483
  authentication_method: currentMember.is_oauth ? AuthenticationMethods.OAUTH : AuthenticationMethods.NON_OAUTH
36502
36484
  });
@@ -36508,9 +36490,9 @@ const Connecting$2 = (props) => {
36508
36490
  const postMessageFunctions = useContext(PostMessageContext);
36509
36491
  const connectingRef = useRef(null);
36510
36492
  const { api } = useApi();
36511
- const jobSchedule = useSelector((state) => state.connect.jobSchedule);
36512
36493
  const [message, setMessage] = useState(CONNECTING_MESSAGES.STARTING);
36513
36494
  const [timedOut, setTimedOut] = useState(false);
36495
+ const [connectingError, setConnectingError] = useState(null);
36514
36496
  const activeJob = getActiveJob(jobSchedule);
36515
36497
  const needsToInitializeJobSchedule = jobSchedule.isInitialized === false;
36516
36498
  function handleMemberPoll(pollingState) {
@@ -36549,10 +36531,20 @@ const Connecting$2 = (props) => {
36549
36531
  }, 1500);
36550
36532
  }
36551
36533
  }, [needsToInitializeJobSchedule, jobSchedule]);
36534
+ const memberUseCasesWereProvidedInConfig = () => Boolean(connectConfig?.use_cases?.length);
36535
+ const memberIsMissingAConfiguredUseCase = () => {
36536
+ const currentUseCases = currentMember?.use_cases;
36537
+ if (!currentUseCases || !Array.isArray(currentUseCases)) {
36538
+ return true;
36539
+ }
36540
+ const newUseCases = connectConfig.use_cases;
36541
+ return newUseCases.some((useCase) => currentUseCases.includes(useCase) === false);
36542
+ };
36552
36543
  useEffect(() => {
36553
36544
  if (!needsToInitializeJobSchedule) return () => {
36554
36545
  };
36555
- const sub$ = defer(() => {
36546
+ let sub$ = null;
36547
+ const loadJob$ = defer(() => {
36556
36548
  if (currentMember.most_recent_job_guid) {
36557
36549
  return defer(() => api.loadJob(currentMember.most_recent_job_guid)).pipe(
36558
36550
  // I have to retry here because sometimes this is too fast in sand and
@@ -36564,22 +36556,45 @@ const Connecting$2 = (props) => {
36564
36556
  } else {
36565
36557
  return of(null);
36566
36558
  }
36567
- }).subscribe(
36568
- (job) => dispatch(initializeJobSchedule$1(currentMember, job, connectConfig, isComboJobsEnabled))
36569
- );
36570
- return () => sub$.unsubscribe();
36559
+ });
36560
+ if (memberUseCasesWereProvidedInConfig() && memberIsMissingAConfiguredUseCase()) {
36561
+ api.updateMember({ ...currentMember }, connectConfig).then((updatedMember) => {
36562
+ sub$ = loadJob$.subscribe((job) => {
36563
+ if (onUpsertMember) {
36564
+ onUpsertMember(updatedMember);
36565
+ }
36566
+ dispatch({
36567
+ type: ActionTypes$4.UPDATE_MEMBER_SUCCESS,
36568
+ payload: { item: updatedMember }
36569
+ });
36570
+ return dispatch(
36571
+ initializeJobSchedule$1(currentMember, job, connectConfig, isComboJobsEnabled)
36572
+ );
36573
+ });
36574
+ });
36575
+ } else {
36576
+ sub$ = loadJob$.subscribe(
36577
+ (job) => dispatch(initializeJobSchedule$1(currentMember, job, connectConfig, isComboJobsEnabled))
36578
+ );
36579
+ }
36580
+ return () => sub$?.unsubscribe();
36571
36581
  }, [needsToInitializeJobSchedule]);
36572
36582
  useEffect(() => {
36573
- if (needsToInitializeJobSchedule) return () => {
36583
+ if (needsToInitializeJobSchedule || !activeJob) return () => {
36574
36584
  };
36575
36585
  const connectMember$ = defer(() => {
36576
36586
  const needsJobStarted = currentMember.is_being_aggregated === false;
36577
36587
  const startJob$ = defer(
36578
- () => api.runJob(activeJob.type, currentMember.guid, connectConfig, true)
36588
+ () => api.runJob(activeJob?.type, currentMember.guid, connectConfig, true)
36579
36589
  ).pipe(
36580
36590
  mergeMap(() => api.loadMemberByGuid(currentMember.guid)),
36581
- catchError(() => {
36582
- return of(currentMember);
36591
+ catchError((error) => {
36592
+ const isSafeConflictError = error?.response?.status === 409;
36593
+ if (isSafeConflictError) {
36594
+ return of(currentMember);
36595
+ }
36596
+ setConnectingError(error);
36597
+ throw error;
36583
36598
  })
36584
36599
  );
36585
36600
  return needsJobStarted ? startJob$ : of(currentMember);
@@ -36629,6 +36644,9 @@ const Connecting$2 = (props) => {
36629
36644
  });
36630
36645
  }
36631
36646
  }, [timedOut]);
36647
+ if (connectingError !== null) {
36648
+ throw connectingError;
36649
+ }
36632
36650
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: connectingRef, style: styles.container, children: [
36633
36651
  /* @__PURE__ */ jsxRuntimeExports.jsxs(SlideDown, { delay: getNextDelay(), children: [
36634
36652
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: styles.logoHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ConnectLogoHeader, { institutionGuid: institution.guid }) }),
@@ -49863,6 +49881,8 @@ function loadConnectFromMicrodepositConfig(config, api) {
49863
49881
  );
49864
49882
  }
49865
49883
  class VerifyNotEnabled extends Error {
49884
+ entity;
49885
+ entity_type;
49866
49886
  constructor(entity, message, entity_type) {
49867
49887
  super(message);
49868
49888
  this.name = "VerifyNotEnabled";
@@ -53361,13 +53381,12 @@ const PostMessageContext = createContext({ onPostMessage: () => {
53361
53381
  const ConnectWidget = ({
53362
53382
  onPostMessage = () => {
53363
53383
  },
53364
- language = { locale: "en", custom_copy_namespace: "" },
53365
53384
  onAnalyticPageview = () => {
53366
53385
  },
53367
53386
  showTooSmallDialog = true,
53368
53387
  ...props
53369
53388
  }) => {
53370
- initGettextLocaleData(language);
53389
+ initGettextLocaleData(props.language);
53371
53390
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Provider_default, { store: Store, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ConnectedTokenProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(PostMessageContext.Provider, { value: { onPostMessage }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(WidgetDimensionObserver, { heightOffset: 0, children: [
53372
53391
  showTooSmallDialog && /* @__PURE__ */ jsxRuntimeExports.jsx(TooSmallDialog, { onAnalyticPageview }),
53373
53392
  /* @__PURE__ */ jsxRuntimeExports.jsx(Connect$2, { onAnalyticPageview, ...props })