woodsportal-client-sdk 4.0.4-dev.9 → 4.0.7-dev.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.
Files changed (65) hide show
  1. package/dist/adapters/angular/index.d.ts +1 -0
  2. package/dist/adapters/angular/index.js +6 -4
  3. package/dist/adapters/angular/index.js.map +1 -1
  4. package/dist/adapters/react/index.d.ts +1 -0
  5. package/dist/adapters/react/index.js +6 -4
  6. package/dist/adapters/react/index.js.map +1 -1
  7. package/dist/adapters/vue/index.d.ts +1 -0
  8. package/dist/adapters/vue/index.js +6 -4
  9. package/dist/adapters/vue/index.js.map +1 -1
  10. package/dist/auth-error-codes-D7CXVBEN.js +3 -0
  11. package/dist/auth-error-codes-D7CXVBEN.js.map +1 -0
  12. package/dist/auth-interceptor-policy-BSY5KIIA.js +5 -0
  13. package/dist/auth-interceptor-policy-BSY5KIIA.js.map +1 -0
  14. package/dist/auth-utils-XIHNYE63.js +5 -0
  15. package/dist/{auth-utils-MNMC2QGX.js.map → auth-utils-XIHNYE63.js.map} +1 -1
  16. package/dist/{chunk-4AMFPSO2.js → chunk-4IKGBHFJ.js} +451 -258
  17. package/dist/chunk-4IKGBHFJ.js.map +1 -0
  18. package/dist/chunk-55MIERLJ.js +3 -0
  19. package/dist/chunk-55MIERLJ.js.map +1 -0
  20. package/dist/chunk-6ROV3EE2.js +160 -0
  21. package/dist/chunk-6ROV3EE2.js.map +1 -0
  22. package/dist/{chunk-IBKBTIT6.js → chunk-7OGXVANB.js} +6 -6
  23. package/dist/{chunk-IBKBTIT6.js.map → chunk-7OGXVANB.js.map} +1 -1
  24. package/dist/chunk-ADOV2R3A.js +571 -0
  25. package/dist/chunk-ADOV2R3A.js.map +1 -0
  26. package/dist/chunk-COHBSTHF.js +82 -0
  27. package/dist/chunk-COHBSTHF.js.map +1 -0
  28. package/dist/chunk-DZC3DJUO.js +156 -0
  29. package/dist/chunk-DZC3DJUO.js.map +1 -0
  30. package/dist/{chunk-2TG7X2ML.js → chunk-GVXA7OKY.js} +12 -11
  31. package/dist/chunk-GVXA7OKY.js.map +1 -0
  32. package/dist/chunk-J33YFZCS.js +162 -0
  33. package/dist/chunk-J33YFZCS.js.map +1 -0
  34. package/dist/{chunk-7Q6HRCUA.js → chunk-OF5OLEE5.js} +3 -3
  35. package/dist/{chunk-7Q6HRCUA.js.map → chunk-OF5OLEE5.js.map} +1 -1
  36. package/dist/{chunk-ZEJGWZK3.js → chunk-U66LWTVC.js} +1242 -1269
  37. package/dist/chunk-U66LWTVC.js.map +1 -0
  38. package/dist/{chunk-VCYJAVD3.js → chunk-WNBF6FKG.js} +165 -13
  39. package/dist/chunk-WNBF6FKG.js.map +1 -0
  40. package/dist/chunk-YOT5RW3R.js +306 -0
  41. package/dist/chunk-YOT5RW3R.js.map +1 -0
  42. package/dist/cross-tab-session-OJKWJSNT.js +9 -0
  43. package/dist/cross-tab-session-OJKWJSNT.js.map +1 -0
  44. package/dist/entries/auth.d.ts +15 -3
  45. package/dist/entries/auth.js +9 -4
  46. package/dist/entries/auth.js.map +1 -1
  47. package/dist/entries/crm.d.ts +1 -0
  48. package/dist/entries/crm.js +10 -6
  49. package/dist/entries/crm.js.map +1 -1
  50. package/dist/{http-errors-DqdtoJ1y.d.ts → http-errors-_XPPqJ_a.d.ts} +190 -9
  51. package/dist/index.d.ts +138 -3
  52. package/dist/index.js +16 -9
  53. package/dist/index.js.map +1 -1
  54. package/dist/refresh-lock-UW5RRRTD.js +72 -0
  55. package/dist/refresh-lock-UW5RRRTD.js.map +1 -0
  56. package/dist/storage-migration-OCOML7VA.js +4 -0
  57. package/dist/storage-migration-OCOML7VA.js.map +1 -0
  58. package/package.json +11 -9
  59. package/dist/auth-utils-MNMC2QGX.js +0 -3
  60. package/dist/chunk-2TG7X2ML.js.map +0 -1
  61. package/dist/chunk-4AMFPSO2.js.map +0 -1
  62. package/dist/chunk-QPSCMK4W.js +0 -237
  63. package/dist/chunk-QPSCMK4W.js.map +0 -1
  64. package/dist/chunk-VCYJAVD3.js.map +0 -1
  65. package/dist/chunk-ZEJGWZK3.js.map +0 -1
@@ -1,104 +1,44 @@
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-ZEJGWZK3.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, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, tableUiActions, ticketHubspotObjectTypeId, tableStore, actions2, userStore, fileStore, actions7, emailStore, actions5, noteStore, actions4, tableUiStore, resetAllStore, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-U66LWTVC.js';
2
+ import { configureLogger, setIframeStorageMode, setRefreshBufferSeconds, config, setRefreshCallback, isHttpTracingEnabled, logger, getAccessToken, sanitizeAxiosErrorData, setRefreshToken, storAccessToken, storage, HUBSPOT_DATA, setRuntimeHttpClientHubContext, refreshSession, ensureValidRefresh, HUB_ID, DEV_PORTAL_ID, DEV_API_URL, isAccessTokenExpired } from './chunk-ADOV2R3A.js';
3
+ import { AuthErrorCode } from './chunk-COHBSTHF.js';
4
+ import { configureStorageKeys } from './chunk-YOT5RW3R.js';
3
5
  import axios2 from 'axios';
4
6
 
5
- // src/main/core/utils/localStorage.ts
6
- var memory = /* @__PURE__ */ new Map();
7
- var memoryStore = {
8
- getItem(key) {
9
- return memory.has(key) ? memory.get(key) : null;
10
- },
11
- setItem(key, value) {
12
- memory.set(key, value);
13
- },
14
- removeItem(key) {
15
- memory.delete(key);
16
- }
17
- };
18
- function resolveStore() {
19
- if (typeof globalThis === "undefined") {
20
- return memoryStore;
21
- }
22
- const ls = globalThis.localStorage;
23
- if (!ls || typeof ls.getItem !== "function") {
24
- return memoryStore;
25
- }
26
- try {
27
- const probeKey = "__woodsportal_client_sdk_ls_probe__";
28
- ls.setItem(probeKey, "1");
29
- ls.removeItem(probeKey);
30
- return ls;
31
- } catch {
32
- return memoryStore;
33
- }
34
- }
35
- var storage = {
36
- set: (key, value) => {
37
- resolveStore().setItem(key, JSON.stringify(value));
38
- },
39
- get: (key) => {
40
- const item = resolveStore().getItem(key);
41
- return item ? JSON.parse(item) : null;
42
- },
43
- remove: (key) => {
44
- resolveStore().removeItem(key);
45
- }
46
- };
47
-
48
- // src/main/core/utils/runtime-hub-context.ts
49
- var initializedHubId = "";
50
- var initializedDevPortalId = "";
51
- var initializedDevApiUrl = "";
52
- function setRuntimeHttpClientHubContext(partial) {
53
- if (partial.hubId != null) {
54
- initializedHubId = partial.hubId;
55
- }
56
- if (partial.devPortalId != null) {
57
- initializedDevPortalId = partial.devPortalId;
58
- }
59
- if (partial.devApiUrl != null) {
60
- initializedDevApiUrl = partial.devApiUrl;
61
- }
62
- }
63
- function getRuntimeHttpClientHubId() {
64
- return initializedHubId;
65
- }
66
- function getRuntimeHttpClientDevPortalId() {
67
- return initializedDevPortalId;
7
+ // src/main/core/http/visibility-refresh-scheduler.ts
8
+ var visibilityStop = null;
9
+ function startVisibilityRefreshScheduler(options) {
10
+ if (typeof window === "undefined") {
11
+ return () => void 0;
12
+ }
13
+ visibilityStop?.();
14
+ const intervalMs = options.intervalMs ?? 6e4;
15
+ const tick = () => {
16
+ if (document.visibilityState !== "visible") return;
17
+ if (!options.shouldRefresh()) return;
18
+ void options.refresh();
19
+ };
20
+ const onVisibility = () => {
21
+ if (document.visibilityState === "visible") {
22
+ void tick();
23
+ }
24
+ };
25
+ const intervalId = window.setInterval(tick, intervalMs);
26
+ document.addEventListener("visibilitychange", onVisibility);
27
+ window.addEventListener("focus", onVisibility);
28
+ const stop = () => {
29
+ window.clearInterval(intervalId);
30
+ document.removeEventListener("visibilitychange", onVisibility);
31
+ window.removeEventListener("focus", onVisibility);
32
+ if (visibilityStop === stop) {
33
+ visibilityStop = null;
34
+ }
35
+ };
36
+ visibilityStop = stop;
37
+ return stop;
68
38
  }
69
- function getRuntimeHttpClientDevApiUrl() {
70
- return initializedDevApiUrl;
39
+ function stopVisibilityRefreshScheduler() {
40
+ visibilityStop?.();
71
41
  }
72
-
73
- // src/main/core/utils/hub-context.ts
74
- function readStorageField(key) {
75
- const hubSpotData = storage.get(HUBSPOT_DATA);
76
- const value = hubSpotData?.[key];
77
- return value != null && String(value).trim() !== "" ? String(value) : "";
78
- }
79
- var config = {
80
- get hubId() {
81
- return readStorageField(HUB_ID) || getRuntimeHttpClientHubId();
82
- },
83
- get devPortalId() {
84
- return readStorageField(DEV_PORTAL_ID) || getRuntimeHttpClientDevPortalId();
85
- },
86
- get portalId() {
87
- return readStorageField(PORTAL_ID);
88
- },
89
- get devApiUrl() {
90
- return readStorageField(DEV_API_URL) || getRuntimeHttpClientDevApiUrl();
91
- }
92
- };
93
- var setConfig = {
94
- setDevPortalId(portalId) {
95
- const existing = storage.get(HUBSPOT_DATA) || {};
96
- storage.set(HUBSPOT_DATA, {
97
- ...existing,
98
- [PORTAL_ID]: portalId
99
- });
100
- }
101
- };
102
42
  var SERVICE_UNAVAILABLE_MESSAGE = "Service temporarily unavailable. Please try again in a few minutes.";
103
43
  var SERVICE_UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
104
44
  function classifyHttpError(error) {
@@ -154,6 +94,9 @@ var editorPreviewMockHandler = null;
154
94
  function setEditorPreviewMockHandler(handler) {
155
95
  editorPreviewMockHandler = handler;
156
96
  }
97
+ function isEditorPreviewMockActive() {
98
+ return editorPreviewMockHandler != null;
99
+ }
157
100
  async function resolveEditorPreviewMock(config4) {
158
101
  if (!editorPreviewMockHandler) {
159
102
  return null;
@@ -167,6 +110,7 @@ var API_ENDPOINTS = {
167
110
  PRE_LOGIN: "/api/auth/pre-login",
168
111
  LOGIN: "/api/auth/login",
169
112
  AUTH_REFRESH: "/api/auth/refresh",
113
+ AUTH_REFRESH_COOKIE: "/api/auth/refresh-cookie",
170
114
  FORGET_PASSWORD: "/api/auth/forget-password",
171
115
  RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
172
116
  RESET_PASSWORD: "/api/auth/reset-password",
@@ -342,6 +286,123 @@ function getHttpUrl(config4) {
342
286
  // src/main/core/http/http-client.ts
343
287
  var axiosInstance = null;
344
288
  var config3 = {};
289
+ function buildAuthPolicy() {
290
+ const routes = config3.routes ?? {};
291
+ const base = config3.authPolicy ?? {};
292
+ return {
293
+ routes: {
294
+ unauthorized: routes.unauthorized ?? "/unauthorized",
295
+ login: routes.login ?? "/login",
296
+ twoFa: routes.twoFa ?? "/login/two-fa",
297
+ resendEmail: routes.resendEmail ?? "/resend-email",
298
+ accountSelect: routes.accountSelect ?? "/account-select",
299
+ ...base.routes
300
+ },
301
+ optionalAuthFailurePaths: base.optionalAuthFailurePaths ?? [
302
+ API_ENDPOINTS.MFA_STATUS,
303
+ API_ENDPOINTS.MFA_PREFERENCES,
304
+ API_ENDPOINTS.MFA_TOTP_ENROLL_START,
305
+ API_ENDPOINTS.MFA_TOTP_ENROLL_VERIFY,
306
+ API_ENDPOINTS.MFA_TOTP_DISABLE,
307
+ API_ENDPOINTS.MFA_PHONE_VERIFY_START,
308
+ API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM,
309
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
310
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_VERIFY,
311
+ API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIALS
312
+ ],
313
+ sessionProbePaths: base.sessionProbePaths,
314
+ includeAdminMfaSecurityPrefixes: base.includeAdminMfaSecurityPrefixes ?? true
315
+ };
316
+ }
317
+ function formatUnauthorizedRoute(route) {
318
+ if (route.startsWith("#")) {
319
+ return route;
320
+ }
321
+ if (typeof window !== "undefined" && window.location.hash.startsWith("#/")) {
322
+ return `#${route.startsWith("/") ? route : `/${route}`}`;
323
+ }
324
+ return route;
325
+ }
326
+ function isRecoverableSessionExpiredCode(errorCode) {
327
+ return errorCode === AuthErrorCode.TOKEN_EXPIRED || errorCode === AuthErrorCode.TOKEN_INVALID || errorCode === AuthErrorCode.AUTHENTICATION_FAILED || errorCode === AuthErrorCode.MISSING_REFRESH_TOKEN || errorCode === AuthErrorCode.ACCESS_UNAUTHORIZED;
328
+ }
329
+ function formatLoginRouteWithReturn(loginRoute) {
330
+ const loginPath = loginRoute.startsWith("/") ? loginRoute : `/${loginRoute}`;
331
+ if (typeof window === "undefined") {
332
+ return formatUnauthorizedRoute(loginPath);
333
+ }
334
+ const returnPath = window.location.hash.replace(/^#/, "") || window.location.pathname;
335
+ if (!returnPath || returnPath.startsWith("/login")) {
336
+ return formatUnauthorizedRoute(loginPath);
337
+ }
338
+ return formatUnauthorizedRoute(`${loginPath}?r=${encodeURIComponent(returnPath)}`);
339
+ }
340
+ function setBearerAuthorization(requestConfig, token) {
341
+ if (typeof requestConfig.headers?.set === "function") {
342
+ requestConfig.headers.set("Authorization", `Bearer ${token}`);
343
+ return;
344
+ }
345
+ requestConfig.headers.Authorization = `Bearer ${token}`;
346
+ }
347
+ async function handleAuthHttpError(error, axiosInstanceRef) {
348
+ if (!error.response || !error.config) {
349
+ return Promise.reject(error);
350
+ }
351
+ const status = error.response.status;
352
+ if (status !== 401 && status !== 403) {
353
+ return Promise.reject(error);
354
+ }
355
+ const shouldHandleOnPublicPath = config3.skipCurrentPublicPath?.() ?? false;
356
+ const allowUnauthorizedHandling = config3.shouldHandleUnauthorized?.() ?? true;
357
+ if (!shouldHandleOnPublicPath || !allowUnauthorizedHandling) {
358
+ return Promise.reject(error);
359
+ }
360
+ const { parseApiErrorPayload } = await import('./auth-error-codes-D7CXVBEN.js');
361
+ const { persistAuthError, resolveAuthErrorAction } = await import('./auth-interceptor-policy-BSY5KIIA.js');
362
+ const reqConfig = error.config;
363
+ const payload = parseApiErrorPayload(error.response.data);
364
+ const action = resolveAuthErrorAction({
365
+ status,
366
+ errorCode: payload.errorCode,
367
+ url: reqConfig.url,
368
+ skipGlobalAuthRedirect: reqConfig.skipGlobalAuthRedirect,
369
+ isRetryRequest: reqConfig.__isRetryRequest,
370
+ policy: buildAuthPolicy()
371
+ });
372
+ if (action.kind === "reject") {
373
+ return Promise.reject(error);
374
+ }
375
+ if (action.kind === "refresh_retry") {
376
+ try {
377
+ await refreshSession({ force: true });
378
+ } catch {
379
+ }
380
+ const token = getAccessToken();
381
+ if (token) {
382
+ const newConfig = { ...reqConfig, __isRetryRequest: true };
383
+ setBearerAuthorization(newConfig, token);
384
+ return axiosInstanceRef.request(newConfig);
385
+ }
386
+ persistAuthError(payload);
387
+ void config3.onLogout?.();
388
+ const policy = buildAuthPolicy();
389
+ const destination = isRecoverableSessionExpiredCode(payload.errorCode) ? formatLoginRouteWithReturn(policy.routes.login) : formatUnauthorizedRoute(policy.routes.unauthorized);
390
+ if (typeof window !== "undefined") {
391
+ window.location.replace(destination);
392
+ }
393
+ return Promise.reject(error);
394
+ }
395
+ persistAuthError(payload);
396
+ if (action.kind === "logout" || action.kind === "redirect") {
397
+ if (action.clearSession) {
398
+ void config3.onLogout?.();
399
+ }
400
+ if (typeof window !== "undefined") {
401
+ window.location.replace(formatUnauthorizedRoute(action.route));
402
+ }
403
+ }
404
+ return Promise.reject(error);
405
+ }
345
406
  function persistHubContextFromClientConfig(clientConfig) {
346
407
  const existing = storage.get(HUBSPOT_DATA) || {};
347
408
  const next = { ...existing };
@@ -376,7 +437,16 @@ function initializeHttpClient(clientConfig) {
376
437
  if (clientConfig.storageKeys != null) {
377
438
  configureStorageKeys(clientConfig.storageKeys);
378
439
  }
440
+ void import('./storage-migration-OCOML7VA.js').then(({ migrateLegacyStorageKeys }) => {
441
+ migrateLegacyStorageKeys();
442
+ });
443
+ void import('./cross-tab-session-OJKWJSNT.js').then(({ installCrossTabSessionListener }) => {
444
+ installCrossTabSessionListener();
445
+ });
379
446
  setIframeStorageMode(clientConfig.storageMode === "iframe");
447
+ if (typeof clientConfig.refreshBufferSeconds === "number") {
448
+ setRefreshBufferSeconds(clientConfig.refreshBufferSeconds);
449
+ }
380
450
  if (clientConfig.editorPreviewMockHandler !== void 0) {
381
451
  setEditorPreviewMockHandler(clientConfig.editorPreviewMockHandler);
382
452
  }
@@ -444,7 +514,7 @@ function initializeHttpClient(clientConfig) {
444
514
  phase: "complete"
445
515
  });
446
516
  }
447
- if (status != null && status >= 400 && status !== 401) {
517
+ if (status != null && status >= 400 && status !== 401 && status !== 403) {
448
518
  logger.warn("http", "HTTP error response", {
449
519
  method: getHttpMethod(error.config),
450
520
  url: sanitizeHttpUrl(error.config.url),
@@ -455,30 +525,19 @@ function initializeHttpClient(clientConfig) {
455
525
  }
456
526
  notifyServiceUnavailable(error);
457
527
  }
458
- if (error.response && error.response.status === 401) {
459
- const shouldHandleAuthError = config3.skipCurrentPublicPath?.() ?? false;
460
- const allowUnauthorizedHandling = config3.shouldHandleUnauthorized?.() ?? true;
461
- if (shouldHandleAuthError && allowUnauthorizedHandling) {
462
- const payload = error.response.data ?? {};
463
- const data = {
464
- errorCode: payload.errorCode,
465
- errorMessage: payload.errorMessage ?? payload.message,
466
- detailedMessage: payload.detailedMessage,
467
- correlationId: payload.correlationId,
468
- ts: Date.now()
469
- };
470
- if (typeof window !== "undefined" && window.sessionStorage) {
471
- sessionStorage.setItem("authError", JSON.stringify(data));
472
- }
473
- if (config3.routes?.unauthorized && typeof window !== "undefined") {
474
- window.location.replace(`#${config3.routes.unauthorized}`);
475
- }
476
- void config3.onLogout?.();
477
- }
478
- }
479
- return Promise.reject(error);
528
+ return handleAuthHttpError(error, axiosInstance);
480
529
  }
481
530
  );
531
+ stopVisibilityRefreshScheduler();
532
+ startVisibilityRefreshScheduler({
533
+ shouldRefresh: () => !isEditorPreviewMockActive() && isAccessTokenExpired(),
534
+ refresh: async () => {
535
+ try {
536
+ await refreshSession();
537
+ } catch {
538
+ }
539
+ }
540
+ });
482
541
  logger.info("http", "HTTP client initialized", { baseURL });
483
542
  }
484
543
  function getAxiosInstance() {
@@ -493,24 +552,30 @@ function getAxiosInstance() {
493
552
  function formatBooleanSearchParam(key, value) {
494
553
  return value ? `${key}:1` : `${key}:`;
495
554
  }
555
+ async function maybeEnsureValidRefresh() {
556
+ if (isEditorPreviewMockActive()) {
557
+ return;
558
+ }
559
+ await ensureValidRefresh();
560
+ }
496
561
  var HttpClient = class {
497
562
  static async get(url, params, options) {
498
- await ensureValidRefresh();
563
+ await maybeEnsureValidRefresh();
499
564
  const response = await getAxiosInstance().get(url, { params, ...options || {} });
500
565
  return response.data;
501
566
  }
502
567
  static async post(url, data, options) {
503
- await ensureValidRefresh();
568
+ await maybeEnsureValidRefresh();
504
569
  const response = await getAxiosInstance().post(url, data, options);
505
570
  return response.data;
506
571
  }
507
572
  static async put(url, data) {
508
- await ensureValidRefresh();
573
+ await maybeEnsureValidRefresh();
509
574
  const response = await getAxiosInstance().put(url, data);
510
575
  return response.data;
511
576
  }
512
577
  static async delete(url, config4) {
513
- await ensureValidRefresh();
578
+ await maybeEnsureValidRefresh();
514
579
  const response = await getAxiosInstance().delete(url, config4);
515
580
  return response.data;
516
581
  }
@@ -559,17 +624,59 @@ function getFieldErrors(error) {
559
624
  }
560
625
  return null;
561
626
  }
562
- async function getAuthRefreshToken(refreshToken) {
563
- if (refreshToken == null || refreshToken.trim() === "") {
564
- return { token: null, success: false };
627
+ async function postRefreshCookie(headers) {
628
+ const apiUrl = generateApiUrl({
629
+ route: API_ENDPOINTS.AUTH_REFRESH_COOKIE,
630
+ queryParams: { hubId: config.hubId }
631
+ });
632
+ return getAxiosInstance().post(apiUrl, {}, {
633
+ headers,
634
+ withCredentials: true,
635
+ skipGlobalAuthRedirect: true
636
+ });
637
+ }
638
+ function clearSessionAfterRefreshFailure() {
639
+ if (isEditorPreviewMockActive()) {
640
+ return;
641
+ }
642
+ if (config3.shouldHandleUnauthorized?.() === false) {
643
+ return;
565
644
  }
645
+ void config3.onLogout?.();
646
+ }
647
+ async function getAuthRefreshToken(refreshToken) {
566
648
  try {
567
649
  const headers = {};
568
650
  if (config.devPortalId) {
569
651
  headers["X-Dev-Portal-Id"] = config.devPortalId;
570
652
  }
571
- const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
572
- const response = await getAxiosInstance().post(api_url, { refreshToken }, { headers });
653
+ let response;
654
+ if (config3.useCookieRefresh) {
655
+ try {
656
+ response = await postRefreshCookie(headers);
657
+ } catch {
658
+ if (refreshToken == null || refreshToken.trim() === "") {
659
+ return { token: null, success: false };
660
+ }
661
+ const apiUrl = generateApiUrl({
662
+ route: API_ENDPOINTS.AUTH_REFRESH,
663
+ queryParams: { hubId: config.hubId }
664
+ });
665
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, {
666
+ headers,
667
+ skipGlobalAuthRedirect: true
668
+ });
669
+ }
670
+ } else {
671
+ if (refreshToken == null || refreshToken.trim() === "") {
672
+ return { token: null, success: false };
673
+ }
674
+ const apiUrl = generateApiUrl({
675
+ route: API_ENDPOINTS.AUTH_REFRESH,
676
+ queryParams: { hubId: config.hubId }
677
+ });
678
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, { headers });
679
+ }
573
680
  const maybeData = response?.data?.data || response?.data;
574
681
  const tokenData = maybeData?.tokenData || maybeData || {};
575
682
  const newRefreshToken = tokenData?.refreshToken;
@@ -587,13 +694,15 @@ async function getAuthRefreshToken(refreshToken) {
587
694
  setRefreshToken(newRefreshToken, rExpires);
588
695
  }
589
696
  if (typeof token === "string") {
590
- setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
697
+ storAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
591
698
  return { token, success: true };
592
699
  }
700
+ clearSessionAfterRefreshFailure();
593
701
  return { token: null, success: false };
594
702
  } catch (error) {
595
703
  notifyServiceUnavailable(error);
596
704
  logger.error("auth", error, { operation: "token refresh" });
705
+ clearSessionAfterRefreshFailure();
597
706
  return { token: null, success: false };
598
707
  }
599
708
  }
@@ -1059,15 +1168,213 @@ var mfaClient = {
1059
1168
  )
1060
1169
  };
1061
1170
 
1171
+ // src/main/features/crm/helpers/normalize-table-list-params.ts
1172
+ function resolveListTableParams(payload) {
1173
+ const param = tableUiActions.getTableParam(payload?.companyAsMediator, payload?.currentPageOverride);
1174
+ if (payload?.tableParams && typeof payload.tableParams === "object") {
1175
+ return { ...param, ...payload.tableParams };
1176
+ }
1177
+ return { ...param };
1178
+ }
1179
+ function applyBoardPaginationToParams(param, tableParams) {
1180
+ const stageId = tableParams.stageId;
1181
+ const page = tableParams.page;
1182
+ if (stageId !== void 0 && stageId !== null && stageId !== "") {
1183
+ param.stageId = stageId;
1184
+ }
1185
+ if (param.view === "BOARD" && page !== void 0) {
1186
+ param.page = page;
1187
+ }
1188
+ return param;
1189
+ }
1190
+ function finalizeBoardListQueryParams(param, context) {
1191
+ const { stageId, nextPage, view, selectedPipeline } = tableUiStore.getState();
1192
+ const payload = context?.payload;
1193
+ if (view) {
1194
+ param.view = view;
1195
+ }
1196
+ const ticketPipelineContext = payload?.isHome && payload?.hubspotObjectTypeId === "0-5" || payload?.componentName === "object" && payload?.hubspotObjectTypeId === "0-5";
1197
+ if (ticketPipelineContext && !param?.isPrimaryCompany) {
1198
+ param.parentObjectTypeId = "0-1";
1199
+ } else if (ticketPipelineContext && param?.isPrimaryCompany) {
1200
+ param.parentObjectTypeId = "0-2";
1201
+ }
1202
+ if (selectedPipeline !== void 0 && selectedPipeline !== null && selectedPipeline !== "") {
1203
+ param.filterValue = selectedPipeline;
1204
+ }
1205
+ return applyBoardPaginationToParams(param, {
1206
+ stageId,
1207
+ page: stageId ? nextPage : 1
1208
+ });
1209
+ }
1210
+
1211
+ // src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
1212
+ var LIST_QUERY_KEYS = [
1213
+ "sort",
1214
+ "search",
1215
+ "filterPropertyName",
1216
+ "filterOperator",
1217
+ "filterValue",
1218
+ "page",
1219
+ "limit",
1220
+ "view",
1221
+ "mediatorObjectTypeId",
1222
+ "mediatorObjectRecordId",
1223
+ "parentObjectTypeId",
1224
+ "parentObjectRecordId",
1225
+ "stageId",
1226
+ "after"
1227
+ ];
1228
+ var PURGE_FILTER_KEYS = ["sort", "filterPropertyName", "filterOperator", "filterValue", "view", "page", "limit"];
1229
+ function hasPurgeFilterContext(raw) {
1230
+ if (!raw || typeof raw !== "object") {
1231
+ return false;
1232
+ }
1233
+ return PURGE_FILTER_KEYS.some((key) => {
1234
+ const value = raw[key];
1235
+ return value !== void 0 && value !== null && String(value).length > 0;
1236
+ });
1237
+ }
1238
+ function mergeLiveTableUiState(raw) {
1239
+ const state = tableUiStore.getState();
1240
+ const merged = { ...raw ?? {} };
1241
+ if (!merged.sort && state.sort) {
1242
+ merged.sort = state.sort;
1243
+ }
1244
+ if (!merged.search && state.search) {
1245
+ merged.search = state.search;
1246
+ }
1247
+ if (!merged.filterPropertyName && state.filterPropertyName) {
1248
+ merged.filterPropertyName = state.filterPropertyName;
1249
+ }
1250
+ if (!merged.filterOperator && state.filterOperator) {
1251
+ merged.filterOperator = state.filterOperator;
1252
+ }
1253
+ if (!merged.filterValue && state.selectedPipeline) {
1254
+ merged.filterValue = state.selectedPipeline;
1255
+ }
1256
+ if (merged.limit === void 0 && state.limit) {
1257
+ merged.limit = state.limit;
1258
+ }
1259
+ if (merged.page === void 0 && state.page !== void 0 && state.page !== "") {
1260
+ merged.page = state.page;
1261
+ }
1262
+ if (!merged.view && state.view) {
1263
+ merged.view = state.view;
1264
+ }
1265
+ if (merged.isPrimaryCompany === void 0 && state.isPrimaryCompany !== null) {
1266
+ merged.isPrimaryCompany = state.isPrimaryCompany;
1267
+ }
1268
+ return applyBoardPaginationToParams(merged, {
1269
+ stageId: state.stageId,
1270
+ page: state.stageId ? state.nextPage : 1
1271
+ });
1272
+ }
1273
+ function listQueryCacheKey(q) {
1274
+ return JSON.stringify({
1275
+ ...q,
1276
+ stageId: q.stageId ?? ""
1277
+ });
1278
+ }
1279
+ function toCachePurgeListQuery(raw) {
1280
+ if (!raw || typeof raw !== "object") {
1281
+ return { page: 1, limit: 10, view: "LIST" };
1282
+ }
1283
+ const q = {};
1284
+ for (const key of LIST_QUERY_KEYS) {
1285
+ const value = raw[key];
1286
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1287
+ q[key] = String(value);
1288
+ }
1289
+ }
1290
+ if (raw.page !== void 0 && raw.page !== null) {
1291
+ const page = Number(raw.page);
1292
+ if (!Number.isNaN(page) && page > 0) {
1293
+ q.page = page;
1294
+ }
1295
+ }
1296
+ if (raw.limit !== void 0 && raw.limit !== null) {
1297
+ const limit = Number(raw.limit);
1298
+ if (!Number.isNaN(limit) && limit > 0) {
1299
+ q.limit = limit;
1300
+ }
1301
+ }
1302
+ const isPc = raw.isPrimaryCompany ?? raw.isPC;
1303
+ if (isPc !== void 0 && isPc !== null) {
1304
+ q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
1305
+ }
1306
+ const view = raw.view;
1307
+ if (typeof view === "string") {
1308
+ q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
1309
+ }
1310
+ if (Object.keys(q).length === 0) {
1311
+ return { page: 1, limit: 10, view: "LIST" };
1312
+ }
1313
+ if (q.page === void 0) {
1314
+ q.page = 1;
1315
+ }
1316
+ if (q.limit === void 0) {
1317
+ q.limit = 10;
1318
+ }
1319
+ if (q.view === void 0) {
1320
+ q.view = "LIST";
1321
+ }
1322
+ return q;
1323
+ }
1324
+ function expandListPurgeQueriesForCrmWrite(base) {
1325
+ const listQuery = { ...base, view: "LIST" };
1326
+ delete listQuery.stageId;
1327
+ const boardQuery = { ...base, view: "BOARD" };
1328
+ const seen = /* @__PURE__ */ new Set();
1329
+ const expanded = [];
1330
+ for (const query of [listQuery, boardQuery]) {
1331
+ const key = listQueryCacheKey(query);
1332
+ if (seen.has(key)) {
1333
+ continue;
1334
+ }
1335
+ seen.add(key);
1336
+ expanded.push(query);
1337
+ }
1338
+ return expanded;
1339
+ }
1340
+ function resolveCrmListPurgeQuery(options) {
1341
+ let raw;
1342
+ if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
1343
+ raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
1344
+ } else {
1345
+ raw = options.tableQueryParams ?? null;
1346
+ }
1347
+ if (!hasPurgeFilterContext(raw)) {
1348
+ raw = mergeLiveTableUiState(raw);
1349
+ }
1350
+ const base = toCachePurgeListQuery(raw ?? void 0);
1351
+ if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
1352
+ return base;
1353
+ }
1354
+ return {
1355
+ ...base,
1356
+ ...options.writeContext
1357
+ };
1358
+ }
1359
+
1062
1360
  // src/main/core/utils/cache/crmCacheRefresh.ts
1361
+ function buildPostWriteListPurgeTargets(objectTypeId, listQuery, recordIds) {
1362
+ const base = listQuery ?? { page: 1, limit: 10, view: "LIST" };
1363
+ return expandListPurgeQueriesForCrmWrite(base).map((query) => buildCrmListPurgeTarget(objectTypeId, query, recordIds));
1364
+ }
1063
1365
  async function purgeCrmObjectDataCache(options) {
1064
1366
  const result = await purgeCrmListCache(options);
1065
1367
  return result.ok;
1066
1368
  }
1067
1369
  async function purgeCrmListCacheAfterCrmWrite(options) {
1068
- return purgeCrmListCache({
1370
+ const objectTypeId = options.objectTypeId?.trim();
1371
+ if (!objectTypeId) {
1372
+ return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
1373
+ }
1374
+ return purgeCrmCombined({
1069
1375
  ...options,
1070
- postCrmWrite: true
1376
+ postCrmWrite: true,
1377
+ targets: buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds)
1071
1378
  });
1072
1379
  }
1073
1380
  async function purgeCrmDetailAndListAfterCrmWrite(options) {
@@ -1083,7 +1390,7 @@ async function purgeCrmDetailAndListAfterCrmWrite(options) {
1083
1390
  ...options,
1084
1391
  postCrmWrite: true,
1085
1392
  targets: mergePurgeTargets(
1086
- buildCrmListPurgeTarget(objectTypeId, options.listQuery, options.recordIds),
1393
+ ...buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds),
1087
1394
  buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery)
1088
1395
  )
1089
1396
  });
@@ -1255,85 +1562,6 @@ function fieldValue(raw) {
1255
1562
  return s.length > 0 ? s : void 0;
1256
1563
  }
1257
1564
 
1258
- // src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
1259
- var LIST_QUERY_KEYS = [
1260
- "sort",
1261
- "search",
1262
- "filterPropertyName",
1263
- "filterOperator",
1264
- "filterValue",
1265
- "page",
1266
- "limit",
1267
- "view",
1268
- "mediatorObjectTypeId",
1269
- "mediatorObjectRecordId",
1270
- "parentObjectTypeId",
1271
- "parentObjectRecordId",
1272
- "stageId",
1273
- "after"
1274
- ];
1275
- function toCachePurgeListQuery(raw) {
1276
- if (!raw || typeof raw !== "object") {
1277
- return { page: 1, limit: 10, view: "LIST" };
1278
- }
1279
- const q = {};
1280
- for (const key of LIST_QUERY_KEYS) {
1281
- const value = raw[key];
1282
- if (value !== void 0 && value !== null && String(value).length > 0) {
1283
- q[key] = String(value);
1284
- }
1285
- }
1286
- if (raw.page !== void 0 && raw.page !== null) {
1287
- const page = Number(raw.page);
1288
- if (!Number.isNaN(page) && page > 0) {
1289
- q.page = page;
1290
- }
1291
- }
1292
- if (raw.limit !== void 0 && raw.limit !== null) {
1293
- const limit = Number(raw.limit);
1294
- if (!Number.isNaN(limit) && limit > 0) {
1295
- q.limit = limit;
1296
- }
1297
- }
1298
- const isPc = raw.isPrimaryCompany ?? raw.isPC;
1299
- if (isPc !== void 0 && isPc !== null) {
1300
- q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
1301
- }
1302
- const view = raw.view;
1303
- if (typeof view === "string") {
1304
- q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
1305
- }
1306
- if (Object.keys(q).length === 0) {
1307
- return { page: 1, limit: 10, view: "LIST" };
1308
- }
1309
- if (q.page === void 0) {
1310
- q.page = 1;
1311
- }
1312
- if (q.limit === void 0) {
1313
- q.limit = 10;
1314
- }
1315
- if (q.view === void 0) {
1316
- q.view = "LIST";
1317
- }
1318
- return q;
1319
- }
1320
- function resolveCrmListPurgeQuery(options) {
1321
- let raw;
1322
- if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
1323
- raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
1324
- } else {
1325
- raw = options.tableQueryParams ?? null;
1326
- }
1327
- const base = toCachePurgeListQuery(raw ?? void 0);
1328
- if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
1329
- return base;
1330
- }
1331
- return {
1332
- ...base,
1333
- ...options.writeContext
1334
- };
1335
- }
1336
-
1337
1565
  // src/main/core/http/client-context.ts
1338
1566
  function getParamDetails2(...args) {
1339
1567
  return navigationApi.route.getParamDetails(...args);
@@ -1419,6 +1647,8 @@ var authenticationClient = {
1419
1647
  },
1420
1648
  verifyOtp: (data) => mfaClient.verifyOtp(data),
1421
1649
  verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
1650
+ /** Legacy client greenfield signup route (predates /api/auth/* registry). */
1651
+ register: (data) => AuthHttpClient.post("/register", data),
1422
1652
  resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
1423
1653
  resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
1424
1654
  forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
@@ -1467,51 +1697,14 @@ var authenticationClient = {
1467
1697
  user: {
1468
1698
  me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
1469
1699
  profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
1470
- profileUpdate: (props) => HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), props?.payload || {}),
1700
+ profileUpdate: (props) => {
1701
+ const properties = props?.properties ?? props?.payload ?? {};
1702
+ return HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), { properties });
1703
+ },
1471
1704
  changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
1472
1705
  }
1473
1706
  };
1474
1707
 
1475
- // src/main/features/crm/helpers/normalize-table-list-params.ts
1476
- function resolveListTableParams(payload) {
1477
- const param = tableUiActions.getTableParam(payload?.companyAsMediator, payload?.currentPageOverride);
1478
- if (payload?.tableParams && typeof payload.tableParams === "object") {
1479
- return { ...param, ...payload.tableParams };
1480
- }
1481
- return { ...param };
1482
- }
1483
- function applyBoardPaginationToParams(param, tableParams) {
1484
- const stageId = tableParams.stageId;
1485
- const page = tableParams.page;
1486
- if (stageId !== void 0 && stageId !== null && stageId !== "") {
1487
- param.stageId = stageId;
1488
- }
1489
- if (param.view === "BOARD" && page !== void 0) {
1490
- param.page = page;
1491
- }
1492
- return param;
1493
- }
1494
- function finalizeBoardListQueryParams(param, context) {
1495
- const { stageId, nextPage, view, selectedPipeline } = tableUiStore.getState();
1496
- const payload = context?.payload;
1497
- if (view) {
1498
- param.view = view;
1499
- }
1500
- const ticketPipelineContext = payload?.isHome && payload?.hubspotObjectTypeId === "0-5" || payload?.componentName === "object" && payload?.hubspotObjectTypeId === "0-5";
1501
- if (ticketPipelineContext && !param?.isPrimaryCompany) {
1502
- param.parentObjectTypeId = "0-1";
1503
- } else if (ticketPipelineContext && param?.isPrimaryCompany) {
1504
- param.parentObjectTypeId = "0-2";
1505
- }
1506
- if (selectedPipeline !== void 0 && selectedPipeline !== null && selectedPipeline !== "") {
1507
- param.filterValue = selectedPipeline;
1508
- }
1509
- return applyBoardPaginationToParams(param, {
1510
- stageId,
1511
- page: stageId ? nextPage : 1
1512
- });
1513
- }
1514
-
1515
1708
  // src/main/features/crm/client/crm-client.ts
1516
1709
  var crmClient = {
1517
1710
  pipeline: {
@@ -1631,7 +1824,7 @@ var crmClient = {
1631
1824
  },
1632
1825
  create: async (props = null) => {
1633
1826
  const { paramsObject } = getParamDetails2({ type: props?.componentName });
1634
- const cardParentMerge = props?.componentName === "association" ? true : false;
1827
+ const cardParentMerge = props?.componentName === "association" || props?.componentName === "sidebarAssociation" ? true : false;
1635
1828
  const body = mergeRecordWriteBody(props?.payload, paramsObject, {
1636
1829
  cardParentMerge,
1637
1830
  addAnother: props?.params?.addAnother
@@ -1942,7 +2135,7 @@ var engagementClient = {
1942
2135
  },
1943
2136
  file: {
1944
2137
  list: (props = null) => {
1945
- const { setListQueryParams } = actions6;
2138
+ const { setListQueryParams } = actions7;
1946
2139
  setListQueryParams(props?.queryParams ?? {});
1947
2140
  const params = {
1948
2141
  // hubId: config.hubId,
@@ -2209,6 +2402,6 @@ function createMutation(mutationFn, options) {
2209
2402
  };
2210
2403
  }
2211
2404
 
2212
- 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 };
2213
- //# sourceMappingURL=chunk-4AMFPSO2.js.map
2214
- //# sourceMappingURL=chunk-4AMFPSO2.js.map
2405
+ export { Client, SERVICE_UNAVAILABLE_MESSAGE, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, classifyHttpError, createCachePurgeJob, createMutation, extractEngagementItemIdFromWriteResponse, extractHubspotRecordIdFromWriteResponse, getAuthRefreshToken, getFieldErrors, getFormErrors, getHttpErrorMessage, initializeHttpClient, isServiceUnavailableError, mergePurgeTargets, navigationApi, purgeCrmCombined, purgeCrmDetailAndListAfterCrmWrite, purgeCrmListCache, purgeCrmListCacheAfterCrmWrite, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, purgeEngagementCachesAfterCrmWrite, resolveCrmListPurgeQuery, resolveListTableParams, setEditorPreviewMockHandler, startVisibilityRefreshScheduler, stopVisibilityRefreshScheduler, toCachePurgeListQuery };
2406
+ //# sourceMappingURL=chunk-4IKGBHFJ.js.map
2407
+ //# sourceMappingURL=chunk-4IKGBHFJ.js.map