woodsportal-client-sdk 4.0.4-dev.2 → 4.0.4-dev.20

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.
Files changed (49) hide show
  1. package/README.md +2 -0
  2. package/dist/adapters/angular/index.d.ts +2 -1
  3. package/dist/adapters/angular/index.js +4 -4
  4. package/dist/adapters/react/index.d.ts +2 -1
  5. package/dist/adapters/react/index.js +4 -4
  6. package/dist/adapters/vue/index.d.ts +2 -1
  7. package/dist/adapters/vue/index.js +4 -4
  8. package/dist/auth-error-codes-D7CXVBEN.js +3 -0
  9. package/dist/auth-error-codes-D7CXVBEN.js.map +1 -0
  10. package/dist/auth-interceptor-policy-F7JIJWSQ.js +4 -0
  11. package/dist/auth-interceptor-policy-F7JIJWSQ.js.map +1 -0
  12. package/dist/auth-utils-VTD5TFYE.js +3 -0
  13. package/dist/{auth-utils-MNMC2QGX.js.map → auth-utils-VTD5TFYE.js.map} +1 -1
  14. package/dist/{cache-purge-G5WkHckd.d.ts → cache-purge-Ca4idzyy.d.ts} +1 -1
  15. package/dist/{chunk-D7XKR2O7.js → chunk-BWZAX23E.js} +11 -10
  16. package/dist/chunk-BWZAX23E.js.map +1 -0
  17. package/dist/chunk-COHBSTHF.js +82 -0
  18. package/dist/chunk-COHBSTHF.js.map +1 -0
  19. package/dist/{chunk-YEUFUGGT.js → chunk-GLATNYVU.js} +159 -46
  20. package/dist/chunk-GLATNYVU.js.map +1 -0
  21. package/dist/{chunk-GO35W5PN.js → chunk-IUVL2E7K.js} +175 -17
  22. package/dist/chunk-IUVL2E7K.js.map +1 -0
  23. package/dist/{chunk-FDZNMZS4.js → chunk-LSRSCZBI.js} +507 -166
  24. package/dist/chunk-LSRSCZBI.js.map +1 -0
  25. package/dist/{chunk-VEJKNXUE.js → chunk-LYPJXG74.js} +4 -4
  26. package/dist/{chunk-VEJKNXUE.js.map → chunk-LYPJXG74.js.map} +1 -1
  27. package/dist/chunk-MFIGS74G.js +140 -0
  28. package/dist/chunk-MFIGS74G.js.map +1 -0
  29. package/dist/{chunk-6KKVGCXG.js → chunk-ND7HCTXC.js} +3 -3
  30. package/dist/{chunk-6KKVGCXG.js.map → chunk-ND7HCTXC.js.map} +1 -1
  31. package/dist/{chunk-QPSCMK4W.js → chunk-TVUBMDXX.js} +74 -13
  32. package/dist/chunk-TVUBMDXX.js.map +1 -0
  33. package/dist/entries/auth.d.ts +17 -4
  34. package/dist/entries/auth.js +7 -4
  35. package/dist/entries/auth.js.map +1 -1
  36. package/dist/entries/crm.d.ts +4 -3
  37. package/dist/entries/crm.js +5 -5
  38. package/dist/{http-errors-hlKcIsXD.d.ts → http-errors-B41BMjip.d.ts} +252 -15
  39. package/dist/{index-CCwMopD8.d.ts → index-Bh9eY8sA.d.ts} +5 -1
  40. package/dist/index.d.ts +36 -10
  41. package/dist/index.js +11 -8
  42. package/dist/index.js.map +1 -1
  43. package/package.json +4 -3
  44. package/dist/auth-utils-MNMC2QGX.js +0 -3
  45. package/dist/chunk-D7XKR2O7.js.map +0 -1
  46. package/dist/chunk-FDZNMZS4.js.map +0 -1
  47. package/dist/chunk-GO35W5PN.js.map +0 -1
  48. package/dist/chunk-QPSCMK4W.js.map +0 -1
  49. package/dist/chunk-YEUFUGGT.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { getParamDetails, getRouteDetails, updateLink, configureLogger, isHttpTracingEnabled, logger, sanitizeAxiosErrorData, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, tableUiActions, ticketHubspotObjectTypeId, tableStore, actions2, userStore, fileStore, actions6, emailStore, actions5, noteStore, actions4, tableUiStore, resetAllStore, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-YEUFUGGT.js';
2
- import { HUBSPOT_DATA, PORTAL_ID, configureStorageKeys, setIframeStorageMode, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, ensureValidRefresh, DEV_API_URL, DEV_PORTAL_ID, HUB_ID } from './chunk-QPSCMK4W.js';
1
+ import { getParamDetails, getRouteDetails, updateLink, configureLogger, isHttpTracingEnabled, logger, sanitizeAxiosErrorData, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, tableUiActions, ticketHubspotObjectTypeId, tableStore, actions2, userStore, fileStore, actions6, emailStore, actions5, noteStore, actions4, tableUiStore, resetAllStore, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-GLATNYVU.js';
2
+ import { HUBSPOT_DATA, PORTAL_ID, configureStorageKeys, setIframeStorageMode, setRefreshBufferSeconds, setRefreshCallback, getAccessToken, setRefreshToken, storAccessToken, refreshSession, ensureValidRefresh, DEV_API_URL, DEV_PORTAL_ID, HUB_ID, isAccessTokenExpired } from './chunk-TVUBMDXX.js';
3
3
  import axios2 from 'axios';
4
4
 
5
5
  // src/main/core/utils/localStorage.ts
@@ -99,6 +99,42 @@ var setConfig = {
99
99
  });
100
100
  }
101
101
  };
102
+
103
+ // src/main/core/http/visibility-refresh-scheduler.ts
104
+ var visibilityStop = null;
105
+ function startVisibilityRefreshScheduler(options) {
106
+ if (typeof window === "undefined") {
107
+ return () => void 0;
108
+ }
109
+ visibilityStop?.();
110
+ const intervalMs = options.intervalMs ?? 6e4;
111
+ const tick = () => {
112
+ if (document.visibilityState !== "visible") return;
113
+ if (!options.shouldRefresh()) return;
114
+ void options.refresh();
115
+ };
116
+ const onVisibility = () => {
117
+ if (document.visibilityState === "visible") {
118
+ void tick();
119
+ }
120
+ };
121
+ const intervalId = window.setInterval(tick, intervalMs);
122
+ document.addEventListener("visibilitychange", onVisibility);
123
+ window.addEventListener("focus", onVisibility);
124
+ const stop = () => {
125
+ window.clearInterval(intervalId);
126
+ document.removeEventListener("visibilitychange", onVisibility);
127
+ window.removeEventListener("focus", onVisibility);
128
+ if (visibilityStop === stop) {
129
+ visibilityStop = null;
130
+ }
131
+ };
132
+ visibilityStop = stop;
133
+ return stop;
134
+ }
135
+ function stopVisibilityRefreshScheduler() {
136
+ visibilityStop?.();
137
+ }
102
138
  var SERVICE_UNAVAILABLE_MESSAGE = "Service temporarily unavailable. Please try again in a few minutes.";
103
139
  var SERVICE_UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
104
140
  function classifyHttpError(error) {
@@ -167,6 +203,7 @@ var API_ENDPOINTS = {
167
203
  PRE_LOGIN: "/api/auth/pre-login",
168
204
  LOGIN: "/api/auth/login",
169
205
  AUTH_REFRESH: "/api/auth/refresh",
206
+ AUTH_REFRESH_COOKIE: "/api/auth/refresh-cookie",
170
207
  FORGET_PASSWORD: "/api/auth/forget-password",
171
208
  RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
172
209
  RESET_PASSWORD: "/api/auth/reset-password",
@@ -186,6 +223,9 @@ var API_ENDPOINTS = {
186
223
  MFA_PREFERENCES: "/api/auth/mfa/preferences",
187
224
  MFA_PHONE_VERIFY_START: "/api/auth/mfa/phone/verify/start",
188
225
  MFA_PHONE_VERIFY_CONFIRM: "/api/auth/mfa/phone/verify/confirm",
226
+ MFA_PHONE_UNVERIFY: "/api/auth/mfa/phone/unverify",
227
+ MFA_BACKUP_CODES_REGENERATE: "/api/auth/mfa/backup-codes/regenerate",
228
+ MFA_OPT_OUT: "/api/auth/mfa/opt-out",
189
229
  MFA_TOTP_ENROLL_START: "/api/auth/mfa/totp/enroll/start",
190
230
  MFA_TOTP_ENROLL_VERIFY: "/api/auth/mfa/totp/enroll/verify",
191
231
  MFA_TOTP_DISABLE: "/api/auth/mfa/totp/disable",
@@ -203,6 +243,8 @@ var API_ENDPOINTS = {
203
243
  SECURITY_SESSIONS: "/api/auth/security/sessions",
204
244
  SECURITY_SESSION_REVOKE: "/api/auth/security/sessions/${familyId}/revoke",
205
245
  SECURITY_SESSIONS_REVOKE_OTHERS: "/api/auth/security/sessions/revoke-others",
246
+ // Login bootstrap (portal MFA policy + SSO providers)
247
+ LOGIN_BOOTSTRAP: "/api/auth/login/bootstrap",
206
248
  // SSO
207
249
  SSO_DETAILS: "/api/auth/sso/active",
208
250
  SSO_URL: "/api/auth/sso/authorize",
@@ -337,6 +379,108 @@ function getHttpUrl(config4) {
337
379
  // src/main/core/http/http-client.ts
338
380
  var axiosInstance = null;
339
381
  var config3 = {};
382
+ function buildAuthPolicy() {
383
+ const routes = config3.routes ?? {};
384
+ const base = config3.authPolicy ?? {};
385
+ return {
386
+ routes: {
387
+ unauthorized: routes.unauthorized ?? "/unauthorized",
388
+ login: routes.login ?? "/login",
389
+ twoFa: routes.twoFa ?? "/login/two-fa",
390
+ resendEmail: routes.resendEmail ?? "/resend-email",
391
+ accountSelect: routes.accountSelect ?? "/account-select",
392
+ ...base.routes
393
+ },
394
+ optionalAuthFailurePaths: base.optionalAuthFailurePaths ?? [
395
+ API_ENDPOINTS.MFA_STATUS,
396
+ API_ENDPOINTS.MFA_PREFERENCES,
397
+ API_ENDPOINTS.MFA_TOTP_ENROLL_START,
398
+ API_ENDPOINTS.MFA_TOTP_ENROLL_VERIFY,
399
+ API_ENDPOINTS.MFA_TOTP_DISABLE,
400
+ API_ENDPOINTS.MFA_PHONE_VERIFY_START,
401
+ API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM,
402
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
403
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_VERIFY,
404
+ API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIALS
405
+ ],
406
+ sessionProbePaths: base.sessionProbePaths,
407
+ includeAdminMfaSecurityPrefixes: base.includeAdminMfaSecurityPrefixes ?? true
408
+ };
409
+ }
410
+ function formatUnauthorizedRoute(route) {
411
+ if (route.startsWith("#")) {
412
+ return route;
413
+ }
414
+ if (typeof window !== "undefined" && window.location.hash.startsWith("#/")) {
415
+ return `#${route.startsWith("/") ? route : `/${route}`}`;
416
+ }
417
+ return route;
418
+ }
419
+ function setBearerAuthorization(requestConfig, token) {
420
+ if (typeof requestConfig.headers?.set === "function") {
421
+ requestConfig.headers.set("Authorization", `Bearer ${token}`);
422
+ return;
423
+ }
424
+ requestConfig.headers.Authorization = `Bearer ${token}`;
425
+ }
426
+ async function handleAuthHttpError(error, axiosInstanceRef) {
427
+ if (!error.response || !error.config) {
428
+ return Promise.reject(error);
429
+ }
430
+ const status = error.response.status;
431
+ if (status !== 401 && status !== 403) {
432
+ return Promise.reject(error);
433
+ }
434
+ const shouldHandleOnPublicPath = config3.skipCurrentPublicPath?.() ?? false;
435
+ const allowUnauthorizedHandling = config3.shouldHandleUnauthorized?.() ?? true;
436
+ if (!shouldHandleOnPublicPath || !allowUnauthorizedHandling) {
437
+ return Promise.reject(error);
438
+ }
439
+ const { parseApiErrorPayload } = await import('./auth-error-codes-D7CXVBEN.js');
440
+ const { persistAuthError, resolveAuthErrorAction } = await import('./auth-interceptor-policy-F7JIJWSQ.js');
441
+ const reqConfig = error.config;
442
+ const payload = parseApiErrorPayload(error.response.data);
443
+ const action = resolveAuthErrorAction({
444
+ status,
445
+ errorCode: payload.errorCode,
446
+ url: reqConfig.url,
447
+ skipGlobalAuthRedirect: reqConfig.skipGlobalAuthRedirect,
448
+ isRetryRequest: reqConfig.__isRetryRequest,
449
+ policy: buildAuthPolicy()
450
+ });
451
+ if (action.kind === "reject") {
452
+ return Promise.reject(error);
453
+ }
454
+ if (action.kind === "refresh_retry") {
455
+ try {
456
+ await refreshSession({ force: true });
457
+ } catch {
458
+ }
459
+ const token = getAccessToken();
460
+ if (token) {
461
+ const newConfig = { ...reqConfig, __isRetryRequest: true };
462
+ setBearerAuthorization(newConfig, token);
463
+ return axiosInstanceRef.request(newConfig);
464
+ }
465
+ persistAuthError(payload);
466
+ const unauthorizedRoute = formatUnauthorizedRoute(buildAuthPolicy().routes.unauthorized);
467
+ if (typeof window !== "undefined") {
468
+ window.location.replace(unauthorizedRoute);
469
+ }
470
+ void config3.onLogout?.();
471
+ return Promise.reject(error);
472
+ }
473
+ persistAuthError(payload);
474
+ if (action.kind === "logout" || action.kind === "redirect") {
475
+ if (action.clearSession) {
476
+ void config3.onLogout?.();
477
+ }
478
+ if (typeof window !== "undefined") {
479
+ window.location.replace(formatUnauthorizedRoute(action.route));
480
+ }
481
+ }
482
+ return Promise.reject(error);
483
+ }
340
484
  function persistHubContextFromClientConfig(clientConfig) {
341
485
  const existing = storage.get(HUBSPOT_DATA) || {};
342
486
  const next = { ...existing };
@@ -372,6 +516,9 @@ function initializeHttpClient(clientConfig) {
372
516
  configureStorageKeys(clientConfig.storageKeys);
373
517
  }
374
518
  setIframeStorageMode(clientConfig.storageMode === "iframe");
519
+ if (typeof clientConfig.refreshBufferSeconds === "number") {
520
+ setRefreshBufferSeconds(clientConfig.refreshBufferSeconds);
521
+ }
375
522
  if (clientConfig.editorPreviewMockHandler !== void 0) {
376
523
  setEditorPreviewMockHandler(clientConfig.editorPreviewMockHandler);
377
524
  }
@@ -439,7 +586,7 @@ function initializeHttpClient(clientConfig) {
439
586
  phase: "complete"
440
587
  });
441
588
  }
442
- if (status != null && status >= 400 && status !== 401) {
589
+ if (status != null && status >= 400 && status !== 401 && status !== 403) {
443
590
  logger.warn("http", "HTTP error response", {
444
591
  method: getHttpMethod(error.config),
445
592
  url: sanitizeHttpUrl(error.config.url),
@@ -450,30 +597,19 @@ function initializeHttpClient(clientConfig) {
450
597
  }
451
598
  notifyServiceUnavailable(error);
452
599
  }
453
- if (error.response && error.response.status === 401) {
454
- const shouldHandleAuthError = config3.skipCurrentPublicPath?.() ?? false;
455
- const allowUnauthorizedHandling = config3.shouldHandleUnauthorized?.() ?? true;
456
- if (shouldHandleAuthError && allowUnauthorizedHandling) {
457
- const payload = error.response.data ?? {};
458
- const data = {
459
- errorCode: payload.errorCode,
460
- errorMessage: payload.errorMessage ?? payload.message,
461
- detailedMessage: payload.detailedMessage,
462
- correlationId: payload.correlationId,
463
- ts: Date.now()
464
- };
465
- if (typeof window !== "undefined" && window.sessionStorage) {
466
- sessionStorage.setItem("authError", JSON.stringify(data));
467
- }
468
- if (config3.routes?.unauthorized && typeof window !== "undefined") {
469
- window.location.replace(`#${config3.routes.unauthorized}`);
470
- }
471
- void config3.onLogout?.();
472
- }
473
- }
474
- return Promise.reject(error);
600
+ return handleAuthHttpError(error, axiosInstance);
475
601
  }
476
602
  );
603
+ stopVisibilityRefreshScheduler();
604
+ startVisibilityRefreshScheduler({
605
+ shouldRefresh: () => isAccessTokenExpired(),
606
+ refresh: async () => {
607
+ try {
608
+ await refreshSession();
609
+ } catch {
610
+ }
611
+ }
612
+ });
477
613
  logger.info("http", "HTTP client initialized", { baseURL });
478
614
  }
479
615
  function getAxiosInstance() {
@@ -515,9 +651,22 @@ var HttpClient = class {
515
651
  ).join(";");
516
652
  }
517
653
  };
654
+ function mergeAuthRequestOptions(options) {
655
+ const devPortalId = config.devPortalId;
656
+ if (!devPortalId && !options?.headers) {
657
+ return options;
658
+ }
659
+ return {
660
+ ...options,
661
+ headers: {
662
+ ...devPortalId ? { "X-Dev-Portal-Id": devPortalId } : {},
663
+ ...options?.headers
664
+ }
665
+ };
666
+ }
518
667
  var AuthHttpClient = class {
519
- static async get(url, params) {
520
- const response = await getAxiosInstance().get(url, { params });
668
+ static async get(url, params, options) {
669
+ const response = await getAxiosInstance().get(url, { params, ...mergeAuthRequestOptions(options) });
521
670
  return response.data;
522
671
  }
523
672
  static async post(url, data, options) {
@@ -541,17 +690,50 @@ function getFieldErrors(error) {
541
690
  }
542
691
  return null;
543
692
  }
693
+ async function postRefreshCookie(headers) {
694
+ const apiUrl = generateApiUrl({
695
+ route: API_ENDPOINTS.AUTH_REFRESH_COOKIE,
696
+ queryParams: { hubId: config.hubId }
697
+ });
698
+ return getAxiosInstance().post(apiUrl, {}, {
699
+ headers,
700
+ withCredentials: true,
701
+ skipGlobalAuthRedirect: true
702
+ });
703
+ }
544
704
  async function getAuthRefreshToken(refreshToken) {
545
- if (refreshToken == null || refreshToken.trim() === "") {
546
- return { token: null, success: false };
547
- }
548
705
  try {
549
706
  const headers = {};
550
707
  if (config.devPortalId) {
551
708
  headers["X-Dev-Portal-Id"] = config.devPortalId;
552
709
  }
553
- const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
554
- const response = await getAxiosInstance().post(api_url, { refreshToken }, { headers });
710
+ let response;
711
+ if (config3.useCookieRefresh) {
712
+ try {
713
+ response = await postRefreshCookie(headers);
714
+ } catch {
715
+ if (refreshToken == null || refreshToken.trim() === "") {
716
+ return { token: null, success: false };
717
+ }
718
+ const apiUrl = generateApiUrl({
719
+ route: API_ENDPOINTS.AUTH_REFRESH,
720
+ queryParams: { hubId: config.hubId }
721
+ });
722
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, {
723
+ headers,
724
+ skipGlobalAuthRedirect: true
725
+ });
726
+ }
727
+ } else {
728
+ if (refreshToken == null || refreshToken.trim() === "") {
729
+ return { token: null, success: false };
730
+ }
731
+ const apiUrl = generateApiUrl({
732
+ route: API_ENDPOINTS.AUTH_REFRESH,
733
+ queryParams: { hubId: config.hubId }
734
+ });
735
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, { headers });
736
+ }
555
737
  const maybeData = response?.data?.data || response?.data;
556
738
  const tokenData = maybeData?.tokenData || maybeData || {};
557
739
  const newRefreshToken = tokenData?.refreshToken;
@@ -569,7 +751,7 @@ async function getAuthRefreshToken(refreshToken) {
569
751
  setRefreshToken(newRefreshToken, rExpires);
570
752
  }
571
753
  if (typeof token === "string") {
572
- setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
754
+ storAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
573
755
  return { token, success: true };
574
756
  }
575
757
  return { token: null, success: false };
@@ -926,8 +1108,20 @@ var mfaClient = {
926
1108
  }),
927
1109
  data
928
1110
  ),
929
- startPhoneVerify: (data) => HttpClient.post(API_ENDPOINTS.MFA_PHONE_VERIFY_START, data),
930
- confirmPhoneVerify: (data) => HttpClient.post(API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM, data),
1111
+ startPhoneVerify: (data, query) => HttpClient.post(
1112
+ generateApiUrl({
1113
+ route: API_ENDPOINTS.MFA_PHONE_VERIFY_START,
1114
+ queryParams: mfaPortalQuery(query?.portalId)
1115
+ }),
1116
+ data
1117
+ ),
1118
+ confirmPhoneVerify: (data, query) => HttpClient.post(
1119
+ generateApiUrl({
1120
+ route: API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM,
1121
+ queryParams: mfaPortalQuery(query?.portalId)
1122
+ }),
1123
+ data
1124
+ ),
931
1125
  totpEnrollStart: (query) => HttpClient.post(
932
1126
  generateApiUrl({
933
1127
  route: API_ENDPOINTS.MFA_TOTP_ENROLL_START,
@@ -942,7 +1136,34 @@ var mfaClient = {
942
1136
  }),
943
1137
  data
944
1138
  ),
945
- totpDisable: (data) => HttpClient.post(API_ENDPOINTS.MFA_TOTP_DISABLE, data),
1139
+ totpDisable: (data, query) => HttpClient.post(
1140
+ generateApiUrl({
1141
+ route: API_ENDPOINTS.MFA_TOTP_DISABLE,
1142
+ queryParams: mfaPortalQuery(query?.portalId)
1143
+ }),
1144
+ data
1145
+ ),
1146
+ phoneUnverify: (data, query) => HttpClient.post(
1147
+ generateApiUrl({
1148
+ route: API_ENDPOINTS.MFA_PHONE_UNVERIFY,
1149
+ queryParams: mfaPortalQuery(query?.portalId)
1150
+ }),
1151
+ data
1152
+ ),
1153
+ backupCodesRegenerate: (data, query) => HttpClient.post(
1154
+ generateApiUrl({
1155
+ route: API_ENDPOINTS.MFA_BACKUP_CODES_REGENERATE,
1156
+ queryParams: mfaPortalQuery(query?.portalId)
1157
+ }),
1158
+ data
1159
+ ),
1160
+ optOut: (data, query) => HttpClient.post(
1161
+ generateApiUrl({
1162
+ route: API_ENDPOINTS.MFA_OPT_OUT,
1163
+ queryParams: mfaPortalQuery(query?.portalId)
1164
+ }),
1165
+ data
1166
+ ),
946
1167
  webauthnRegisterOptions: (query) => HttpClient.post(
947
1168
  generateApiUrl({
948
1169
  route: API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
@@ -1002,15 +1223,213 @@ var mfaClient = {
1002
1223
  )
1003
1224
  };
1004
1225
 
1226
+ // src/main/features/crm/helpers/normalize-table-list-params.ts
1227
+ function resolveListTableParams(payload) {
1228
+ const param = tableUiActions.getTableParam(payload?.companyAsMediator, payload?.currentPageOverride);
1229
+ if (payload?.tableParams && typeof payload.tableParams === "object") {
1230
+ return { ...param, ...payload.tableParams };
1231
+ }
1232
+ return { ...param };
1233
+ }
1234
+ function applyBoardPaginationToParams(param, tableParams) {
1235
+ const stageId = tableParams.stageId;
1236
+ const page = tableParams.page;
1237
+ if (stageId !== void 0 && stageId !== null && stageId !== "") {
1238
+ param.stageId = stageId;
1239
+ }
1240
+ if (param.view === "BOARD" && page !== void 0) {
1241
+ param.page = page;
1242
+ }
1243
+ return param;
1244
+ }
1245
+ function finalizeBoardListQueryParams(param, context) {
1246
+ const { stageId, nextPage, view, selectedPipeline } = tableUiStore.getState();
1247
+ const payload = context?.payload;
1248
+ if (view) {
1249
+ param.view = view;
1250
+ }
1251
+ const ticketPipelineContext = payload?.isHome && payload?.hubspotObjectTypeId === "0-5" || payload?.componentName === "object" && payload?.hubspotObjectTypeId === "0-5";
1252
+ if (ticketPipelineContext && !param?.isPrimaryCompany) {
1253
+ param.parentObjectTypeId = "0-1";
1254
+ } else if (ticketPipelineContext && param?.isPrimaryCompany) {
1255
+ param.parentObjectTypeId = "0-2";
1256
+ }
1257
+ if (selectedPipeline !== void 0 && selectedPipeline !== null && selectedPipeline !== "") {
1258
+ param.filterValue = selectedPipeline;
1259
+ }
1260
+ return applyBoardPaginationToParams(param, {
1261
+ stageId,
1262
+ page: stageId ? nextPage : 1
1263
+ });
1264
+ }
1265
+
1266
+ // src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
1267
+ var LIST_QUERY_KEYS = [
1268
+ "sort",
1269
+ "search",
1270
+ "filterPropertyName",
1271
+ "filterOperator",
1272
+ "filterValue",
1273
+ "page",
1274
+ "limit",
1275
+ "view",
1276
+ "mediatorObjectTypeId",
1277
+ "mediatorObjectRecordId",
1278
+ "parentObjectTypeId",
1279
+ "parentObjectRecordId",
1280
+ "stageId",
1281
+ "after"
1282
+ ];
1283
+ var PURGE_FILTER_KEYS = ["sort", "filterPropertyName", "filterOperator", "filterValue", "view", "page", "limit"];
1284
+ function hasPurgeFilterContext(raw) {
1285
+ if (!raw || typeof raw !== "object") {
1286
+ return false;
1287
+ }
1288
+ return PURGE_FILTER_KEYS.some((key) => {
1289
+ const value = raw[key];
1290
+ return value !== void 0 && value !== null && String(value).length > 0;
1291
+ });
1292
+ }
1293
+ function mergeLiveTableUiState(raw) {
1294
+ const state = tableUiStore.getState();
1295
+ const merged = { ...raw ?? {} };
1296
+ if (!merged.sort && state.sort) {
1297
+ merged.sort = state.sort;
1298
+ }
1299
+ if (!merged.search && state.search) {
1300
+ merged.search = state.search;
1301
+ }
1302
+ if (!merged.filterPropertyName && state.filterPropertyName) {
1303
+ merged.filterPropertyName = state.filterPropertyName;
1304
+ }
1305
+ if (!merged.filterOperator && state.filterOperator) {
1306
+ merged.filterOperator = state.filterOperator;
1307
+ }
1308
+ if (!merged.filterValue && state.selectedPipeline) {
1309
+ merged.filterValue = state.selectedPipeline;
1310
+ }
1311
+ if (merged.limit === void 0 && state.limit) {
1312
+ merged.limit = state.limit;
1313
+ }
1314
+ if (merged.page === void 0 && state.page !== void 0 && state.page !== "") {
1315
+ merged.page = state.page;
1316
+ }
1317
+ if (!merged.view && state.view) {
1318
+ merged.view = state.view;
1319
+ }
1320
+ if (merged.isPrimaryCompany === void 0 && state.isPrimaryCompany !== null) {
1321
+ merged.isPrimaryCompany = state.isPrimaryCompany;
1322
+ }
1323
+ return applyBoardPaginationToParams(merged, {
1324
+ stageId: state.stageId,
1325
+ page: state.stageId ? state.nextPage : 1
1326
+ });
1327
+ }
1328
+ function listQueryCacheKey(q) {
1329
+ return JSON.stringify({
1330
+ ...q,
1331
+ stageId: q.stageId ?? ""
1332
+ });
1333
+ }
1334
+ function toCachePurgeListQuery(raw) {
1335
+ if (!raw || typeof raw !== "object") {
1336
+ return { page: 1, limit: 10, view: "LIST" };
1337
+ }
1338
+ const q = {};
1339
+ for (const key of LIST_QUERY_KEYS) {
1340
+ const value = raw[key];
1341
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1342
+ q[key] = String(value);
1343
+ }
1344
+ }
1345
+ if (raw.page !== void 0 && raw.page !== null) {
1346
+ const page = Number(raw.page);
1347
+ if (!Number.isNaN(page) && page > 0) {
1348
+ q.page = page;
1349
+ }
1350
+ }
1351
+ if (raw.limit !== void 0 && raw.limit !== null) {
1352
+ const limit = Number(raw.limit);
1353
+ if (!Number.isNaN(limit) && limit > 0) {
1354
+ q.limit = limit;
1355
+ }
1356
+ }
1357
+ const isPc = raw.isPrimaryCompany ?? raw.isPC;
1358
+ if (isPc !== void 0 && isPc !== null) {
1359
+ q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
1360
+ }
1361
+ const view = raw.view;
1362
+ if (typeof view === "string") {
1363
+ q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
1364
+ }
1365
+ if (Object.keys(q).length === 0) {
1366
+ return { page: 1, limit: 10, view: "LIST" };
1367
+ }
1368
+ if (q.page === void 0) {
1369
+ q.page = 1;
1370
+ }
1371
+ if (q.limit === void 0) {
1372
+ q.limit = 10;
1373
+ }
1374
+ if (q.view === void 0) {
1375
+ q.view = "LIST";
1376
+ }
1377
+ return q;
1378
+ }
1379
+ function expandListPurgeQueriesForCrmWrite(base) {
1380
+ const listQuery = { ...base, view: "LIST" };
1381
+ delete listQuery.stageId;
1382
+ const boardQuery = { ...base, view: "BOARD" };
1383
+ const seen = /* @__PURE__ */ new Set();
1384
+ const expanded = [];
1385
+ for (const query of [listQuery, boardQuery]) {
1386
+ const key = listQueryCacheKey(query);
1387
+ if (seen.has(key)) {
1388
+ continue;
1389
+ }
1390
+ seen.add(key);
1391
+ expanded.push(query);
1392
+ }
1393
+ return expanded;
1394
+ }
1395
+ function resolveCrmListPurgeQuery(options) {
1396
+ let raw;
1397
+ if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
1398
+ raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
1399
+ } else {
1400
+ raw = options.tableQueryParams ?? null;
1401
+ }
1402
+ if (!hasPurgeFilterContext(raw)) {
1403
+ raw = mergeLiveTableUiState(raw);
1404
+ }
1405
+ const base = toCachePurgeListQuery(raw ?? void 0);
1406
+ if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
1407
+ return base;
1408
+ }
1409
+ return {
1410
+ ...base,
1411
+ ...options.writeContext
1412
+ };
1413
+ }
1414
+
1005
1415
  // src/main/core/utils/cache/crmCacheRefresh.ts
1416
+ function buildPostWriteListPurgeTargets(objectTypeId, listQuery, recordIds) {
1417
+ const base = listQuery ?? { page: 1, limit: 10, view: "LIST" };
1418
+ return expandListPurgeQueriesForCrmWrite(base).map((query) => buildCrmListPurgeTarget(objectTypeId, query, recordIds));
1419
+ }
1006
1420
  async function purgeCrmObjectDataCache(options) {
1007
1421
  const result = await purgeCrmListCache(options);
1008
1422
  return result.ok;
1009
1423
  }
1010
1424
  async function purgeCrmListCacheAfterCrmWrite(options) {
1011
- return purgeCrmListCache({
1425
+ const objectTypeId = options.objectTypeId?.trim();
1426
+ if (!objectTypeId) {
1427
+ return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
1428
+ }
1429
+ return purgeCrmCombined({
1012
1430
  ...options,
1013
- postCrmWrite: true
1431
+ postCrmWrite: true,
1432
+ targets: buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds)
1014
1433
  });
1015
1434
  }
1016
1435
  async function purgeCrmDetailAndListAfterCrmWrite(options) {
@@ -1026,7 +1445,7 @@ async function purgeCrmDetailAndListAfterCrmWrite(options) {
1026
1445
  ...options,
1027
1446
  postCrmWrite: true,
1028
1447
  targets: mergePurgeTargets(
1029
- buildCrmListPurgeTarget(objectTypeId, options.listQuery, options.recordIds),
1448
+ ...buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds),
1030
1449
  buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery)
1031
1450
  )
1032
1451
  });
@@ -1198,85 +1617,6 @@ function fieldValue(raw) {
1198
1617
  return s.length > 0 ? s : void 0;
1199
1618
  }
1200
1619
 
1201
- // src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
1202
- var LIST_QUERY_KEYS = [
1203
- "sort",
1204
- "search",
1205
- "filterPropertyName",
1206
- "filterOperator",
1207
- "filterValue",
1208
- "page",
1209
- "limit",
1210
- "view",
1211
- "mediatorObjectTypeId",
1212
- "mediatorObjectRecordId",
1213
- "parentObjectTypeId",
1214
- "parentObjectRecordId",
1215
- "stageId",
1216
- "after"
1217
- ];
1218
- function toCachePurgeListQuery(raw) {
1219
- if (!raw || typeof raw !== "object") {
1220
- return { page: 1, limit: 10, view: "LIST" };
1221
- }
1222
- const q = {};
1223
- for (const key of LIST_QUERY_KEYS) {
1224
- const value = raw[key];
1225
- if (value !== void 0 && value !== null && String(value).length > 0) {
1226
- q[key] = String(value);
1227
- }
1228
- }
1229
- if (raw.page !== void 0 && raw.page !== null) {
1230
- const page = Number(raw.page);
1231
- if (!Number.isNaN(page) && page > 0) {
1232
- q.page = page;
1233
- }
1234
- }
1235
- if (raw.limit !== void 0 && raw.limit !== null) {
1236
- const limit = Number(raw.limit);
1237
- if (!Number.isNaN(limit) && limit > 0) {
1238
- q.limit = limit;
1239
- }
1240
- }
1241
- const isPc = raw.isPrimaryCompany ?? raw.isPC;
1242
- if (isPc !== void 0 && isPc !== null) {
1243
- q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
1244
- }
1245
- const view = raw.view;
1246
- if (typeof view === "string") {
1247
- q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
1248
- }
1249
- if (Object.keys(q).length === 0) {
1250
- return { page: 1, limit: 10, view: "LIST" };
1251
- }
1252
- if (q.page === void 0) {
1253
- q.page = 1;
1254
- }
1255
- if (q.limit === void 0) {
1256
- q.limit = 10;
1257
- }
1258
- if (q.view === void 0) {
1259
- q.view = "LIST";
1260
- }
1261
- return q;
1262
- }
1263
- function resolveCrmListPurgeQuery(options) {
1264
- let raw;
1265
- if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
1266
- raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
1267
- } else {
1268
- raw = options.tableQueryParams ?? null;
1269
- }
1270
- const base = toCachePurgeListQuery(raw ?? void 0);
1271
- if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
1272
- return base;
1273
- }
1274
- return {
1275
- ...base,
1276
- ...options.writeContext
1277
- };
1278
- }
1279
-
1280
1620
  // src/main/core/http/client-context.ts
1281
1621
  function getParamDetails2(...args) {
1282
1622
  return navigationApi.route.getParamDetails(...args);
@@ -1330,7 +1670,24 @@ var mergeRecordWriteBody = (payload, paramsObject, options) => {
1330
1670
  // src/main/features/auth/client/authentication-client.ts
1331
1671
  var authenticationClient = {
1332
1672
  authentication: {
1333
- preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
1673
+ preLogin: (data) => {
1674
+ const queryParams = {};
1675
+ if (data.hubId != null) {
1676
+ queryParams.hubId = data.hubId;
1677
+ }
1678
+ const resolvedPortalId = data.portalId ?? (config?.devPortalId != null && String(config.devPortalId).trim() !== "" ? Number(config.devPortalId) : void 0);
1679
+ if (resolvedPortalId != null && !Number.isNaN(resolvedPortalId)) {
1680
+ queryParams.portalId = resolvedPortalId;
1681
+ }
1682
+ const email = data.email ?? data.username;
1683
+ return AuthHttpClient.post(
1684
+ generateApiUrl({
1685
+ route: API_ENDPOINTS.PRE_LOGIN,
1686
+ queryParams: Object.keys(queryParams).length > 0 ? queryParams : void 0
1687
+ }),
1688
+ { email }
1689
+ );
1690
+ },
1334
1691
  login: (data) => {
1335
1692
  const queryParams = config.hubId ? { hubId: config.hubId } : null;
1336
1693
  return AuthHttpClient.post(
@@ -1345,6 +1702,8 @@ var authenticationClient = {
1345
1702
  },
1346
1703
  verifyOtp: (data) => mfaClient.verifyOtp(data),
1347
1704
  verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
1705
+ /** Legacy client greenfield signup route (predates /api/auth/* registry). */
1706
+ register: (data) => AuthHttpClient.post("/register", data),
1348
1707
  resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
1349
1708
  resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
1350
1709
  forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
@@ -1367,7 +1726,23 @@ var authenticationClient = {
1367
1726
  queryParams: { hubId: payload.hubId }
1368
1727
  }),
1369
1728
  { code: payload.code }
1370
- )
1729
+ ),
1730
+ getLoginBootstrap: (payload) => {
1731
+ const queryParams = {};
1732
+ if (payload?.hubId != null) {
1733
+ queryParams.hubId = payload.hubId;
1734
+ }
1735
+ const resolvedPortalId = payload?.portalId ?? (config?.devPortalId != null && String(config.devPortalId).trim() !== "" ? Number(config.devPortalId) : void 0);
1736
+ if (resolvedPortalId != null && !Number.isNaN(resolvedPortalId)) {
1737
+ queryParams.portalId = resolvedPortalId;
1738
+ }
1739
+ return AuthHttpClient.get(
1740
+ generateApiUrl({
1741
+ route: API_ENDPOINTS.LOGIN_BOOTSTRAP,
1742
+ queryParams: Object.keys(queryParams).length > 0 ? queryParams : void 0
1743
+ })
1744
+ );
1745
+ }
1371
1746
  },
1372
1747
  sso: {
1373
1748
  getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
@@ -1377,51 +1752,14 @@ var authenticationClient = {
1377
1752
  user: {
1378
1753
  me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
1379
1754
  profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
1380
- profileUpdate: (props) => HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), props?.payload || {}),
1755
+ profileUpdate: (props) => {
1756
+ const properties = props?.properties ?? props?.payload ?? {};
1757
+ return HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), { properties });
1758
+ },
1381
1759
  changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
1382
1760
  }
1383
1761
  };
1384
1762
 
1385
- // src/main/features/crm/helpers/normalize-table-list-params.ts
1386
- function resolveListTableParams(payload) {
1387
- const param = tableUiActions.getTableParam(payload?.companyAsMediator, payload?.currentPageOverride);
1388
- if (payload?.tableParams && typeof payload.tableParams === "object") {
1389
- return { ...param, ...payload.tableParams };
1390
- }
1391
- return { ...param };
1392
- }
1393
- function applyBoardPaginationToParams(param, tableParams) {
1394
- const stageId = tableParams.stageId;
1395
- const page = tableParams.page;
1396
- if (stageId !== void 0 && stageId !== null && stageId !== "") {
1397
- param.stageId = stageId;
1398
- }
1399
- if (param.view === "BOARD" && page !== void 0) {
1400
- param.page = page;
1401
- }
1402
- return param;
1403
- }
1404
- function finalizeBoardListQueryParams(param, context) {
1405
- const { stageId, nextPage, view, selectedPipeline } = tableUiStore.getState();
1406
- const payload = context?.payload;
1407
- const userData = context?.userData;
1408
- if (view) {
1409
- param.view = view;
1410
- }
1411
- const ticketPipelineContext = payload?.isHome && payload?.hubspotObjectTypeId === "0-5" || payload?.componentName === "object" && payload?.hubspotObjectTypeId === "0-5";
1412
- if (ticketPipelineContext && !param?.isPrimaryCompany && userData?.crmProfile?.configurations?.ticket?.pipeline_id) {
1413
- param.filterValue = userData?.crmProfile?.configurations?.ticket?.pipeline_id;
1414
- } else if (ticketPipelineContext && param?.isPrimaryCompany && userData?.crmProfile?.response?.associations?.COMPANY?.configurations?.ticket?.pipeline_id) {
1415
- param.filterValue = userData?.crmProfile?.response?.associations?.COMPANY?.configurations?.ticket?.pipeline_id;
1416
- } else if (selectedPipeline !== void 0 && selectedPipeline !== null && selectedPipeline !== "") {
1417
- param.filterValue = selectedPipeline;
1418
- }
1419
- return applyBoardPaginationToParams(param, {
1420
- stageId,
1421
- page: stageId ? nextPage : 1
1422
- });
1423
- }
1424
-
1425
1763
  // src/main/features/crm/client/crm-client.ts
1426
1764
  var crmClient = {
1427
1765
  pipeline: {
@@ -1511,7 +1849,7 @@ var crmClient = {
1511
1849
  param.parentObjectTypeId = parentObjectTypeId;
1512
1850
  }
1513
1851
  param.parentAccessLabel = parentAccessLabel;
1514
- finalizeBoardListQueryParams(param, { payload, userData });
1852
+ finalizeBoardListQueryParams(param, { payload});
1515
1853
  setObjectsQueryParams(param);
1516
1854
  param.cache = payload?.cache;
1517
1855
  const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
@@ -1541,7 +1879,7 @@ var crmClient = {
1541
1879
  },
1542
1880
  create: async (props = null) => {
1543
1881
  const { paramsObject } = getParamDetails2({ type: props?.componentName });
1544
- const cardParentMerge = props?.componentName === "association" ? true : false;
1882
+ const cardParentMerge = props?.componentName === "association" || props?.componentName === "sidebarAssociation" ? true : false;
1545
1883
  const body = mergeRecordWriteBody(props?.payload, paramsObject, {
1546
1884
  cardParentMerge,
1547
1885
  addAnother: props?.params?.addAnother
@@ -1648,6 +1986,9 @@ var crmClient = {
1648
1986
  multiObjectsQueryParams,
1649
1987
  writeContext
1650
1988
  });
1989
+ if (props?.view === "board") {
1990
+ body.options.view = "board";
1991
+ }
1651
1992
  const response = await HttpClient.put(apiUrl, body);
1652
1993
  const objectTypeId = props?.hubspotObjectTypeId ?? props?.params?.objectId;
1653
1994
  const recordId = props?.params?.id;
@@ -2116,6 +2457,6 @@ function createMutation(mutationFn, options) {
2116
2457
  };
2117
2458
  }
2118
2459
 
2119
- export { Client, SERVICE_UNAVAILABLE_MESSAGE, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, classifyHttpError, config, createCachePurgeJob, createMutation, extractEngagementItemIdFromWriteResponse, extractHubspotRecordIdFromWriteResponse, getAuthRefreshToken, getFieldErrors, getFormErrors, getHttpErrorMessage, initializeHttpClient, isServiceUnavailableError, mergePurgeTargets, navigationApi, purgeCrmCombined, purgeCrmDetailAndListAfterCrmWrite, purgeCrmListCache, purgeCrmListCacheAfterCrmWrite, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, purgeEngagementCachesAfterCrmWrite, resolveCrmListPurgeQuery, resolveListTableParams, setConfig, setEditorPreviewMockHandler, storage, toCachePurgeListQuery };
2120
- //# sourceMappingURL=chunk-FDZNMZS4.js.map
2121
- //# sourceMappingURL=chunk-FDZNMZS4.js.map
2460
+ export { Client, SERVICE_UNAVAILABLE_MESSAGE, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, classifyHttpError, config, createCachePurgeJob, createMutation, extractEngagementItemIdFromWriteResponse, extractHubspotRecordIdFromWriteResponse, getAuthRefreshToken, getFieldErrors, getFormErrors, getHttpErrorMessage, initializeHttpClient, isServiceUnavailableError, mergePurgeTargets, navigationApi, purgeCrmCombined, purgeCrmDetailAndListAfterCrmWrite, purgeCrmListCache, purgeCrmListCacheAfterCrmWrite, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, purgeEngagementCachesAfterCrmWrite, resolveCrmListPurgeQuery, resolveListTableParams, setConfig, setEditorPreviewMockHandler, startVisibilityRefreshScheduler, stopVisibilityRefreshScheduler, storage, toCachePurgeListQuery };
2461
+ //# sourceMappingURL=chunk-LSRSCZBI.js.map
2462
+ //# sourceMappingURL=chunk-LSRSCZBI.js.map