@mxenabled/connect-widget 0.20.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -5087,23 +5087,39 @@ function baseFindIndex$2(array, predicate, fromIndex, fromRight) {
5087
5087
  }
5088
5088
  var _baseFindIndex = baseFindIndex$2;
5089
5089
 
5090
- var reWhitespace = /\s/;
5091
- function trimmedEndIndex$1(string) {
5092
- var index = string.length;
5093
- while (index-- && reWhitespace.test(string.charAt(index))) {
5094
- }
5095
- return index;
5090
+ var _trimmedEndIndex;
5091
+ var hasRequired_trimmedEndIndex;
5092
+
5093
+ function require_trimmedEndIndex () {
5094
+ if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
5095
+ hasRequired_trimmedEndIndex = 1;
5096
+ var reWhitespace = /\s/;
5097
+ function trimmedEndIndex(string) {
5098
+ var index = string.length;
5099
+ while (index-- && reWhitespace.test(string.charAt(index))) {
5100
+ }
5101
+ return index;
5102
+ }
5103
+ _trimmedEndIndex = trimmedEndIndex;
5104
+ return _trimmedEndIndex;
5096
5105
  }
5097
- var _trimmedEndIndex = trimmedEndIndex$1;
5098
5106
 
5099
- var trimmedEndIndex = _trimmedEndIndex;
5100
- var reTrimStart = /^\s+/;
5101
- function baseTrim$1(string) {
5102
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5107
+ var _baseTrim;
5108
+ var hasRequired_baseTrim;
5109
+
5110
+ function require_baseTrim () {
5111
+ if (hasRequired_baseTrim) return _baseTrim;
5112
+ hasRequired_baseTrim = 1;
5113
+ var trimmedEndIndex = require_trimmedEndIndex();
5114
+ var reTrimStart = /^\s+/;
5115
+ function baseTrim(string) {
5116
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
5117
+ }
5118
+ _baseTrim = baseTrim;
5119
+ return _baseTrim;
5103
5120
  }
5104
- var _baseTrim = baseTrim$1;
5105
5121
 
5106
- var baseTrim = _baseTrim, isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5122
+ var baseTrim = require_baseTrim(), isObject$7 = isObject_1, isSymbol$1 = isSymbol_1;
5107
5123
  var NAN = 0 / 0;
5108
5124
  var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
5109
5125
  var reIsBinary = /^0b[01]+$/i;
@@ -8559,7 +8575,7 @@ var hasRequiredTrim;
8559
8575
  function requireTrim () {
8560
8576
  if (hasRequiredTrim) return trim_1;
8561
8577
  hasRequiredTrim = 1;
8562
- var baseToString = _baseToString, baseTrim = _baseTrim, castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8578
+ var baseToString = _baseToString, baseTrim = require_baseTrim(), castSlice = require_castSlice(), charsEndIndex = require_charsEndIndex(), charsStartIndex = require_charsStartIndex(), stringToArray = require_stringToArray(), toString = toString_1;
8563
8579
  function trim(string, chars, guard) {
8564
8580
  string = toString(string);
8565
8581
  if (string && (guard || chars === void 0)) {
@@ -9175,7 +9191,7 @@ const loadConnect = (state, { payload }) => {
9175
9191
  };
9176
9192
  const loadConnectSuccess = (state, action) => {
9177
9193
  const {
9178
- members,
9194
+ members = [],
9179
9195
  member,
9180
9196
  microdeposit,
9181
9197
  config = {},
@@ -9544,7 +9560,7 @@ function getStartingStep(members, member, microdeposit, config, institution, wid
9544
9560
  }
9545
9561
  function getStepFromMember(member) {
9546
9562
  const connection_status = member.connection_status;
9547
- if (member?.most_recent_job_detail_code && canHandleActionableError(member?.most_recent_job_detail_code) || hasNoSingleAccountSelectOptions(member))
9563
+ if (member?.error?.error_code && canHandleActionableError(member?.error?.error_code) || hasNoSingleAccountSelectOptions(member))
9548
9564
  return STEPS.ACTIONABLE_ERROR;
9549
9565
  else if (connection_status === ReadableStatuses$1.CHALLENGED)
9550
9566
  return STEPS.MFA;
@@ -68906,13 +68922,13 @@ const DEFAULT_POLLING_STATE = {
68906
68922
  userMessage: CONNECTING_MESSAGES.STARTING
68907
68923
  // message to show the end user
68908
68924
  };
68909
- function pollMember(memberGuid, api, onPostMessage, sendPosthogEvent) {
68925
+ function pollMember(memberGuid, api, onPostMessage, sendPosthogEvent, clientLocale) {
68910
68926
  return interval(3e3).pipe(
68911
68927
  switchMap(
68912
68928
  () => (
68913
68929
  // Poll the currentMember. Catch errors but don't handle it here
68914
68930
  // the scan will handle it below
68915
- defer(() => api.loadMemberByGuid(memberGuid)).pipe(
68931
+ defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
68916
68932
  mergeMap(
68917
68933
  (member) => defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
68918
68934
  map((job) => {
@@ -70908,6 +70924,9 @@ const CreateMemberForm = (props) => {
70908
70924
  const config = useSelector(selectConfig);
70909
70925
  const isHuman = useSelector((state2) => state2.app.humanEvent);
70910
70926
  const currentMembers = useSelector((state2) => state2.connect.members);
70927
+ const clientLocale = useMemo(() => {
70928
+ return document.querySelector("html")?.getAttribute("lang") || "en";
70929
+ }, [document.querySelector("html")?.getAttribute("lang")]);
70911
70930
  const [isCreatingMember, setIsCreatingMember] = useState(false);
70912
70931
  const [memberCreateError, setMemberCreateError] = useState(null);
70913
70932
  const [userCredentials, setUserCredentials] = useState(null);
@@ -70990,7 +71009,7 @@ const CreateMemberForm = (props) => {
70990
71009
  };
70991
71010
  })
70992
71011
  );
70993
- return defer(() => api.loadMemberByGuid(memberGuid)).pipe(
71012
+ return defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
70994
71013
  mergeMap((member) => {
70995
71014
  const shouldStepToMFA = member.connection_status === ReadableStatuses$1.CHALLENGED;
70996
71015
  return shouldStepToMFA ? stepToMFA$(member) : updateMember$;
@@ -71354,6 +71373,9 @@ const Connecting = (props) => {
71354
71373
  } = props;
71355
71374
  const selectedInstitution = useSelector(getSelectedInstitution);
71356
71375
  const sendPosthogEvent = useAnalyticsEvent();
71376
+ const clientLocale = useMemo(() => {
71377
+ return document.querySelector("html")?.getAttribute("lang") || "en";
71378
+ }, [document.querySelector("html")?.getAttribute("lang")]);
71357
71379
  const currentMember = useSelector(getCurrentMember);
71358
71380
  const isComboJobsEnabled = useSelector(isConnectComboJobsEnabled);
71359
71381
  const jobSchedule = useSelector((state) => state.connect.jobSchedule);
@@ -71479,7 +71501,7 @@ const Connecting = (props) => {
71479
71501
  const startJob$ = defer(
71480
71502
  () => api.runJob(activeJob?.type, currentMember.guid, connectConfig, true)
71481
71503
  ).pipe(
71482
- mergeMap(() => api.loadMemberByGuid(currentMember.guid)),
71504
+ mergeMap(() => api.loadMemberByGuid(currentMember.guid, clientLocale)),
71483
71505
  catchError((error) => {
71484
71506
  const isSafeConflictError = error?.response?.status === 409;
71485
71507
  if (isSafeConflictError) {
@@ -71492,7 +71514,7 @@ const Connecting = (props) => {
71492
71514
  return needsJobStarted ? startJob$ : of(currentMember);
71493
71515
  }).pipe(
71494
71516
  concatMap(
71495
- (member) => pollMember(member.guid, api, onPostMessage, sendPosthogEvent).pipe(
71517
+ (member) => pollMember(member.guid, api, onPostMessage, sendPosthogEvent, clientLocale).pipe(
71496
71518
  tap((pollingState) => handleMemberPoll(pollingState)),
71497
71519
  filter((pollingState) => pollingState.jobIsDone),
71498
71520
  pluck("currentResponse"),
@@ -72118,7 +72140,7 @@ const ActionableError = () => {
72118
72140
  const institution = useSelector((state) => state.connect.selectedInstitution);
72119
72141
  const currentMember = useSelector(getCurrentMember);
72120
72142
  const initialConfig = useSelector(selectInitialConfig);
72121
- const jobDetailCode = currentMember.most_recent_job_detail_code;
72143
+ const jobDetailCode = currentMember.error.error_code;
72122
72144
  const tokens = useTokens();
72123
72145
  const styles = getStyles$A(tokens);
72124
72146
  const getNextDelay = getDelay();
@@ -72127,10 +72149,6 @@ const ActionableError = () => {
72127
72149
  () => ({
72128
72150
  [ACTIONABLE_ERROR_CODES.NO_ELIGIBLE_ACCOUNTS]: {
72129
72151
  title: __("No eligible accounts"),
72130
- userMessage: (institution2) => __(
72131
- "Only checking or savings accounts can be used for transfers. If you have one at %1, make sure to select it when connecting. Otherwise, try connecting a different institution.",
72132
- institution2.name
72133
- ),
72134
72152
  primaryAction: {
72135
72153
  label: __("Log in again"),
72136
72154
  action: () => dispatch({ type: ActionTypes$2.ACTIONABLE_ERROR_LOG_IN_AGAIN })
@@ -72186,7 +72204,7 @@ const ActionableError = () => {
72186
72204
  style: styles.paragraph,
72187
72205
  truncate: false,
72188
72206
  variant: "Paragraph",
72189
- children: messagingMap[jobDetailCode].userMessage(institution)
72207
+ children: currentMember.error.user_message
72190
72208
  }
72191
72209
  )
72192
72210
  ] }),
@@ -76175,6 +76193,9 @@ const ManualAccountForm = React__default.forwardRef(
76175
76193
  useAnalyticsPath(name, path);
76176
76194
  const { api } = useApi();
76177
76195
  const members = useSelector(getMembers);
76196
+ const clientLocale = useMemo(() => {
76197
+ return document.querySelector("html")?.getAttribute("lang") || "en";
76198
+ }, [document.querySelector("html")?.getAttribute("lang")]);
76178
76199
  const [saving, setSaving] = useState(false);
76179
76200
  const [isPersonal, setIsPersonal] = useState(true);
76180
76201
  const [returnField, setReturnField] = useState(null);
@@ -76262,7 +76283,7 @@ const ManualAccountForm = React__default.forwardRef(
76262
76283
  return of(addManualAccountSuccess(savedAccount));
76263
76284
  }
76264
76285
  return zip(
76265
- from(api.loadMemberByGuid(savedAccount.member_guid)),
76286
+ from(api.loadMemberByGuid(savedAccount.member_guid, clientLocale)),
76266
76287
  from(api.loadInstitutionByGuid(savedAccount.institution_guid))
76267
76288
  ).pipe(
76268
76289
  map(([loadedMember, loadedInstitution]) => {
@@ -77515,8 +77536,8 @@ const RenderConnectStep = (props) => {
77515
77536
  }
77516
77537
  );
77517
77538
  } else if (step === STEPS.ACTIONABLE_ERROR) {
77518
- const jobDetailCode = currentMember?.most_recent_job_detail_code ?? null;
77519
- connectStepView = canHandleActionableError(jobDetailCode) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ActionableError, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77539
+ const errorCode = currentMember?.error?.error_code ?? null;
77540
+ connectStepView = canHandleActionableError(errorCode) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ActionableError, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77520
77541
  LoginError,
77521
77542
  {
77522
77543
  institution: selectedInstitution,
@@ -79432,6 +79453,9 @@ const getErrorResource = (err) => {
79432
79453
  const useLoadConnect = () => {
79433
79454
  const { api } = useApi();
79434
79455
  const profiles = useSelector((state) => state.profiles);
79456
+ const clientLocale = useMemo(() => {
79457
+ return document.querySelector("html")?.getAttribute("lang") || "en";
79458
+ }, [document.querySelector("html")?.getAttribute("lang")]);
79435
79459
  const [config, setConfig] = useState({});
79436
79460
  const dispatch = useDispatch();
79437
79461
  const loadConnect = useCallback((config2) => setConfig(config2), [config]);
@@ -79441,7 +79465,7 @@ const useLoadConnect = () => {
79441
79465
  dispatch(loadConnect$1(config));
79442
79466
  let request$;
79443
79467
  if (config.current_member_guid) {
79444
- request$ = loadConnectFromMemberConfig(config, api);
79468
+ request$ = loadConnectFromMemberConfig(config, api, clientLocale);
79445
79469
  } else if (config.current_institution_guid || config.current_institution_code) {
79446
79470
  request$ = loadConnectFromInstitutionConfig(config, api);
79447
79471
  } else if (config.mode === VERIFY_MODE && config.current_microdeposit_guid) {
@@ -79452,9 +79476,9 @@ const useLoadConnect = () => {
79452
79476
  const requestSubscription$ = request$.pipe(
79453
79477
  mergeMap((dependencies) => {
79454
79478
  if (clientSupportRequestedProducts(config, profiles.clientProfile)) {
79455
- return from(api.loadMembers()).pipe(
79479
+ return from(api.loadMembers(clientLocale)).pipe(
79456
79480
  map(
79457
- (members) => loadConnectSuccess$1({
79481
+ (members = []) => loadConnectSuccess$1({
79458
79482
  members,
79459
79483
  widgetProfile: profiles.widgetProfile,
79460
79484
  ...dependencies
@@ -79507,8 +79531,8 @@ const useLoadConnect = () => {
79507
79531
  }, [config]);
79508
79532
  return { loadConnect };
79509
79533
  };
79510
- function loadConnectFromMemberConfig(config, api) {
79511
- return from(api.loadMemberByGuid(config.current_member_guid)).pipe(
79534
+ function loadConnectFromMemberConfig(config, api, clientLocale) {
79535
+ return from(api.loadMemberByGuid(config.current_member_guid, clientLocale)).pipe(
79512
79536
  mergeMap((member) => {
79513
79537
  return defer(() => api.loadInstitutionByGuid(member.institution_guid)).pipe(
79514
79538
  map((institution) => {
@@ -80324,11 +80348,9 @@ const frCa = {
80324
80348
  "Log in again": "Connectez-vous à nouveau",
80325
80349
  "Connect a different institution": "Mettre en relation un autre établissement",
80326
80350
  "No eligible accounts": "Aucun compte admissible",
80327
- "Only checking or savings accounts can be used for transfers. If you have one at %1, make sure to select it when connecting. Otherwise, try connecting a different institution.": "Seuls les comptes chèques ou d’épargne peuvent être utilisés pour les transferts. Si vous en avez un à %1, assurez-vous de le sélectionner lors de la connexion. Sinon, essayez de connecter une autre institution.",
80328
80351
  Required: Required$1,
80329
80352
  "Add financial management?": "Ajouter la gestion financière ?",
80330
80353
  "Yes, add financial management": "Oui, ajoutez la gestion financière",
80331
- "No, just transfers and payment": "Non, juste des virements et des paiements",
80332
80354
  "Add transfers and payments?": "Ajouter des transferts et des paiements ?",
80333
80355
  "Yes, add transfers and payments": "Oui, ajouter des transferts et des paiements",
80334
80356
  "Select an account to connect": "Sélectionnez un compte pour vous connecter",
@@ -80821,7 +80843,6 @@ const es = {
80821
80843
  "Log in again": "Inicie sesión nuevamente",
80822
80844
  "Connect a different institution": "Conecte una institución diferente",
80823
80845
  "No eligible accounts": "No hay cuentas elegibles",
80824
- "Only checking or savings accounts can be used for transfers. If you have one at %1, make sure to select it when connecting. Otherwise, try connecting a different institution.": "Solo se pueden usar cuentas de control o ahorro para transferencias. Si tiene uno en %1, asegúrese de seleccionarlo al conectarlo. De lo contrario, intente conectar una institución diferente.",
80825
80846
  Required: Required,
80826
80847
  "Add financial management?": "¿Añadir gestión financiera?",
80827
80848
  "Yes, add financial management": "Sí, añadir gestión financiera",