woodsportal-client-sdk 4.0.4-dev.13 → 4.0.4-dev.14
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/adapters/angular/index.js +4 -4
- package/dist/adapters/react/index.js +4 -4
- package/dist/adapters/vue/index.js +4 -4
- package/dist/auth-error-codes-D7CXVBEN.js +3 -0
- package/dist/auth-error-codes-D7CXVBEN.js.map +1 -0
- package/dist/auth-interceptor-policy-F7JIJWSQ.js +4 -0
- package/dist/auth-interceptor-policy-F7JIJWSQ.js.map +1 -0
- package/dist/auth-utils-VTD5TFYE.js +3 -0
- package/dist/{auth-utils-MNMC2QGX.js.map → auth-utils-VTD5TFYE.js.map} +1 -1
- package/dist/{chunk-PWTYQHOQ.js → chunk-6ZF2RQJP.js} +3 -3
- package/dist/{chunk-PWTYQHOQ.js.map → chunk-6ZF2RQJP.js.map} +1 -1
- package/dist/chunk-COHBSTHF.js +82 -0
- package/dist/chunk-COHBSTHF.js.map +1 -0
- package/dist/{chunk-ZMZPDWQL.js → chunk-GDMFRKAK.js} +200 -34
- package/dist/chunk-GDMFRKAK.js.map +1 -0
- package/dist/chunk-MFIGS74G.js +140 -0
- package/dist/chunk-MFIGS74G.js.map +1 -0
- package/dist/{chunk-Y3KEQ6U4.js → chunk-MOJFF6SQ.js} +4 -4
- package/dist/{chunk-Y3KEQ6U4.js.map → chunk-MOJFF6SQ.js.map} +1 -1
- package/dist/{chunk-6TWR2S4E.js → chunk-OGOPT4QY.js} +120 -7
- package/dist/chunk-OGOPT4QY.js.map +1 -0
- package/dist/{chunk-VWVUW5QN.js → chunk-Q2ZUUOPY.js} +5 -5
- package/dist/{chunk-VWVUW5QN.js.map → chunk-Q2ZUUOPY.js.map} +1 -1
- package/dist/{chunk-QPSCMK4W.js → chunk-TVUBMDXX.js} +74 -13
- package/dist/chunk-TVUBMDXX.js.map +1 -0
- package/dist/{chunk-S5NYXGLE.js → chunk-ZNXVTTIX.js} +3 -3
- package/dist/{chunk-S5NYXGLE.js.map → chunk-ZNXVTTIX.js.map} +1 -1
- package/dist/entries/auth.d.ts +11 -3
- package/dist/entries/auth.js +7 -4
- package/dist/entries/auth.js.map +1 -1
- package/dist/entries/crm.js +5 -5
- package/dist/{http-errors-DqdtoJ1y.d.ts → http-errors-D8bdo9vF.d.ts} +169 -7
- package/dist/index.d.ts +16 -3
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/auth-utils-MNMC2QGX.js +0 -3
- package/dist/chunk-6TWR2S4E.js.map +0 -1
- package/dist/chunk-QPSCMK4W.js.map +0 -1
- package/dist/chunk-ZMZPDWQL.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/main/core/auth/auth-error-codes.ts
|
|
2
|
+
var AuthErrorCode = {
|
|
3
|
+
AUTHENTICATION_FAILED: "AUTHENTICATION_FAILED",
|
|
4
|
+
TOKEN_INVALID: "AUTH_TOKEN_INVALID",
|
|
5
|
+
TOKEN_EXPIRED: "AUTH_TOKEN_EXPIRED",
|
|
6
|
+
ACCOUNT_LOCKED: "AUTH_ACCOUNT_LOCKED",
|
|
7
|
+
ACCOUNT_DISABLED: "AUTH_ACCOUNT_DISABLED",
|
|
8
|
+
LOGIN_FAILED: "LOGIN_FAILED",
|
|
9
|
+
INVALID_CREDENTIALS: "AUTH_INVALID_CREDENTIALS",
|
|
10
|
+
TWO_FACTOR_REQUIRED: "AUTH_2FA_REQUIRED",
|
|
11
|
+
EMAIL_NOT_VERIFIED: "AUTH_EMAIL_NOT_VERIFIED",
|
|
12
|
+
ACCESS_DENIED: "ACCESS_DENIED",
|
|
13
|
+
ACCESS_FORBIDDEN: "ACCESS_FORBIDDEN",
|
|
14
|
+
ACCESS_UNAUTHORIZED: "ACCESS_UNAUTHORIZED",
|
|
15
|
+
MISSING_REFRESH_TOKEN: "MISSING_REFRESH_TOKEN",
|
|
16
|
+
MISSING_HEADERS: "MISSING_HEADERS",
|
|
17
|
+
OAUTH_PROCESSING_ERROR: "OAUTH_PROCESSING_ERROR",
|
|
18
|
+
HUBSPOT_REAUTH_REQUIRED: "HUBSPOT_REAUTH_REQUIRED",
|
|
19
|
+
PORTAL_INACTIVE: "PORTAL_INACTIVE",
|
|
20
|
+
AMBIGUOUS_HUB_ID: "AMBIGUOUS_HUB_ID",
|
|
21
|
+
COMMERCIAL_ACCESS_EXPIRED: "COMMERCIAL_ACCESS_EXPIRED"
|
|
22
|
+
};
|
|
23
|
+
function parseApiErrorPayload(data) {
|
|
24
|
+
if (!data || typeof data !== "object") {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const payload = data;
|
|
28
|
+
return {
|
|
29
|
+
errorCode: typeof payload.errorCode === "string" ? payload.errorCode : void 0,
|
|
30
|
+
errorMessage: typeof payload.errorMessage === "string" ? payload.errorMessage : typeof payload.message === "string" ? payload.message : void 0,
|
|
31
|
+
detailedMessage: typeof payload.detailedMessage === "string" ? payload.detailedMessage : void 0,
|
|
32
|
+
correlationId: typeof payload.correlationId === "string" ? payload.correlationId : void 0,
|
|
33
|
+
statusCode: typeof payload.statusCode === "number" ? payload.statusCode : void 0,
|
|
34
|
+
category: typeof payload.category === "string" ? payload.category : void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function getUnauthorizedPageCopy(errorCode, fallbackMessage) {
|
|
38
|
+
switch (errorCode) {
|
|
39
|
+
case AuthErrorCode.HUBSPOT_REAUTH_REQUIRED:
|
|
40
|
+
return {
|
|
41
|
+
title: "HubSpot re-authorization required",
|
|
42
|
+
message: fallbackMessage ?? "Reconnect your HubSpot account to continue using WoodsPortal.",
|
|
43
|
+
buttonLabel: "Go to HubSpot Accounts",
|
|
44
|
+
clearSessionOnMount: false
|
|
45
|
+
};
|
|
46
|
+
case AuthErrorCode.ACCOUNT_LOCKED:
|
|
47
|
+
case AuthErrorCode.ACCOUNT_DISABLED:
|
|
48
|
+
return {
|
|
49
|
+
title: "Account unavailable",
|
|
50
|
+
message: fallbackMessage ?? "Your account is locked or disabled. Contact support if you need access.",
|
|
51
|
+
buttonLabel: "Go to Login",
|
|
52
|
+
clearSessionOnMount: true
|
|
53
|
+
};
|
|
54
|
+
case AuthErrorCode.ACCESS_DENIED:
|
|
55
|
+
case AuthErrorCode.ACCESS_FORBIDDEN:
|
|
56
|
+
return {
|
|
57
|
+
title: "Access denied",
|
|
58
|
+
message: fallbackMessage ?? "You do not have permission to perform this action.",
|
|
59
|
+
buttonLabel: "Go to Login",
|
|
60
|
+
clearSessionOnMount: false
|
|
61
|
+
};
|
|
62
|
+
case AuthErrorCode.TOKEN_EXPIRED:
|
|
63
|
+
case AuthErrorCode.TOKEN_INVALID:
|
|
64
|
+
return {
|
|
65
|
+
title: "Session expired",
|
|
66
|
+
message: fallbackMessage ?? "Your session has expired. Please log in again to continue.",
|
|
67
|
+
buttonLabel: "Go to Login",
|
|
68
|
+
clearSessionOnMount: true
|
|
69
|
+
};
|
|
70
|
+
default:
|
|
71
|
+
return {
|
|
72
|
+
title: "Unauthorized",
|
|
73
|
+
message: fallbackMessage ?? "Your session may have expired or you do not have the required permissions. Please log in again to continue.",
|
|
74
|
+
buttonLabel: "Go to Login",
|
|
75
|
+
clearSessionOnMount: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { AuthErrorCode, getUnauthorizedPageCopy, parseApiErrorPayload };
|
|
81
|
+
//# sourceMappingURL=chunk-COHBSTHF.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-COHBSTHF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main/core/auth/auth-error-codes.ts"],"names":[],"mappings":";AACO,IAAM,aAAA,GAAgB;AAAA,EACzB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,aAAA,EAAe,oBAAA;AAAA,EACf,aAAA,EAAe,oBAAA;AAAA,EACf,cAAA,EAAgB,qBAAA;AAAA,EAChB,gB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+ API-ERROR-CODES.md). */\nexport const AuthErrorCode = {\n AUTHENTICATION_FAILED: 'AUTHENTICATION_FAILED',\n TOKEN_INVALID: 'AUTH_TOKEN_INVALID',\n TOKEN_EXPIRED: 'AUTH_TOKEN_EXPIRED',\n ACCOUNT_LOCKED: 'AUTH_ACCOUNT_LOCKED',\n ACCOUNT_DISABLED: 'AUTH_ACCOUNT_DISABLED',\n LOGIN_FAILED: 'LOGIN_FAILED',\n INVALID_CREDENTIALS: 'AUTH_INVALID_CREDENTIALS',\n TWO_FACTOR_REQUIRED: 'AUTH_2FA_REQUIRED',\n EMAIL_NOT_VERIFIED: 'AUTH_EMAIL_NOT_VERIFIED',\n ACCESS_DENIED: 'ACCESS_DENIED',\n ACCESS_FORBIDDEN: 'ACCESS_FORBIDDEN',\n ACCESS_UNAUTHORIZED: 'ACCESS_UNAUTHORIZED',\n MISSING_REFRESH_TOKEN: 'MISSING_REFRESH_TOKEN',\n MISSING_HEADERS: 'MISSING_HEADERS',\n OAUTH_PROCESSING_ERROR: 'OAUTH_PROCESSING_ERROR',\n HUBSPOT_REAUTH_REQUIRED: 'HUBSPOT_REAUTH_REQUIRED',\n PORTAL_INACTIVE: 'PORTAL_INACTIVE',\n AMBIGUOUS_HUB_ID: 'AMBIGUOUS_HUB_ID',\n COMMERCIAL_ACCESS_EXPIRED: 'COMMERCIAL_ACCESS_EXPIRED'\n} as const\n\nexport type AuthErrorCodeValue = (typeof AuthErrorCode)[keyof typeof AuthErrorCode]\n\nexport type ApiErrorPayload = {\n errorCode?: string\n errorMessage?: string\n detailedMessage?: string\n correlationId?: string\n statusCode?: number\n category?: string\n}\n\nexport type StoredAuthError = ApiErrorPayload & { ts?: number }\n\nexport function parseApiErrorPayload(data: unknown): ApiErrorPayload {\n if (!data || typeof data !== 'object') {\n return {}\n }\n const payload = data as Record<string, unknown>\n return {\n errorCode: typeof payload.errorCode === 'string' ? payload.errorCode : undefined,\n errorMessage:\n typeof payload.errorMessage === 'string' ? payload.errorMessage : typeof payload.message === 'string' ? payload.message : undefined,\n detailedMessage: typeof payload.detailedMessage === 'string' ? payload.detailedMessage : undefined,\n correlationId: typeof payload.correlationId === 'string' ? payload.correlationId : undefined,\n statusCode: typeof payload.statusCode === 'number' ? payload.statusCode : undefined,\n category: typeof payload.category === 'string' ? payload.category : undefined\n }\n}\n\nexport type UnauthorizedPageCopy = {\n title: string\n message: string\n buttonLabel: string\n clearSessionOnMount: boolean\n}\n\nexport function getUnauthorizedPageCopy(errorCode?: string, fallbackMessage?: string): UnauthorizedPageCopy {\n switch (errorCode) {\n case AuthErrorCode.HUBSPOT_REAUTH_REQUIRED:\n return {\n title: 'HubSpot re-authorization required',\n message: fallbackMessage ?? 'Reconnect your HubSpot account to continue using WoodsPortal.',\n buttonLabel: 'Go to HubSpot Accounts',\n clearSessionOnMount: false\n }\n case AuthErrorCode.ACCOUNT_LOCKED:\n case AuthErrorCode.ACCOUNT_DISABLED:\n return {\n title: 'Account unavailable',\n message: fallbackMessage ?? 'Your account is locked or disabled. Contact support if you need access.',\n buttonLabel: 'Go to Login',\n clearSessionOnMount: true\n }\n case AuthErrorCode.ACCESS_DENIED:\n case AuthErrorCode.ACCESS_FORBIDDEN:\n return {\n title: 'Access denied',\n message: fallbackMessage ?? 'You do not have permission to perform this action.',\n buttonLabel: 'Go to Login',\n clearSessionOnMount: false\n }\n case AuthErrorCode.TOKEN_EXPIRED:\n case AuthErrorCode.TOKEN_INVALID:\n return {\n title: 'Session expired',\n message: fallbackMessage ?? 'Your session has expired. Please log in again to continue.',\n buttonLabel: 'Go to Login',\n clearSessionOnMount: true\n }\n default:\n return {\n title: 'Unauthorized',\n message:\n fallbackMessage ?? 'Your session may have expired or you do not have the required permissions. Please log in again to continue.',\n buttonLabel: 'Go to Login',\n clearSessionOnMount: true\n }\n }\n}\n"]}
|
|
@@ -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-
|
|
2
|
-
import { HUBSPOT_DATA, PORTAL_ID, configureStorageKeys, setIframeStorageMode, setRefreshCallback, getAccessToken, setRefreshToken,
|
|
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-6ZF2RQJP.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",
|
|
@@ -342,6 +379,108 @@ function getHttpUrl(config4) {
|
|
|
342
379
|
// src/main/core/http/http-client.ts
|
|
343
380
|
var axiosInstance = null;
|
|
344
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
|
+
}
|
|
345
484
|
function persistHubContextFromClientConfig(clientConfig) {
|
|
346
485
|
const existing = storage.get(HUBSPOT_DATA) || {};
|
|
347
486
|
const next = { ...existing };
|
|
@@ -377,6 +516,9 @@ function initializeHttpClient(clientConfig) {
|
|
|
377
516
|
configureStorageKeys(clientConfig.storageKeys);
|
|
378
517
|
}
|
|
379
518
|
setIframeStorageMode(clientConfig.storageMode === "iframe");
|
|
519
|
+
if (typeof clientConfig.refreshBufferSeconds === "number") {
|
|
520
|
+
setRefreshBufferSeconds(clientConfig.refreshBufferSeconds);
|
|
521
|
+
}
|
|
380
522
|
if (clientConfig.editorPreviewMockHandler !== void 0) {
|
|
381
523
|
setEditorPreviewMockHandler(clientConfig.editorPreviewMockHandler);
|
|
382
524
|
}
|
|
@@ -444,7 +586,7 @@ function initializeHttpClient(clientConfig) {
|
|
|
444
586
|
phase: "complete"
|
|
445
587
|
});
|
|
446
588
|
}
|
|
447
|
-
if (status != null && status >= 400 && status !== 401) {
|
|
589
|
+
if (status != null && status >= 400 && status !== 401 && status !== 403) {
|
|
448
590
|
logger.warn("http", "HTTP error response", {
|
|
449
591
|
method: getHttpMethod(error.config),
|
|
450
592
|
url: sanitizeHttpUrl(error.config.url),
|
|
@@ -455,30 +597,19 @@ function initializeHttpClient(clientConfig) {
|
|
|
455
597
|
}
|
|
456
598
|
notifyServiceUnavailable(error);
|
|
457
599
|
}
|
|
458
|
-
|
|
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);
|
|
600
|
+
return handleAuthHttpError(error, axiosInstance);
|
|
480
601
|
}
|
|
481
602
|
);
|
|
603
|
+
stopVisibilityRefreshScheduler();
|
|
604
|
+
startVisibilityRefreshScheduler({
|
|
605
|
+
shouldRefresh: () => isAccessTokenExpired(),
|
|
606
|
+
refresh: async () => {
|
|
607
|
+
try {
|
|
608
|
+
await refreshSession();
|
|
609
|
+
} catch {
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
});
|
|
482
613
|
logger.info("http", "HTTP client initialized", { baseURL });
|
|
483
614
|
}
|
|
484
615
|
function getAxiosInstance() {
|
|
@@ -559,17 +690,50 @@ function getFieldErrors(error) {
|
|
|
559
690
|
}
|
|
560
691
|
return null;
|
|
561
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
|
+
}
|
|
562
704
|
async function getAuthRefreshToken(refreshToken) {
|
|
563
|
-
if (refreshToken == null || refreshToken.trim() === "") {
|
|
564
|
-
return { token: null, success: false };
|
|
565
|
-
}
|
|
566
705
|
try {
|
|
567
706
|
const headers = {};
|
|
568
707
|
if (config.devPortalId) {
|
|
569
708
|
headers["X-Dev-Portal-Id"] = config.devPortalId;
|
|
570
709
|
}
|
|
571
|
-
|
|
572
|
-
|
|
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
|
+
}
|
|
573
737
|
const maybeData = response?.data?.data || response?.data;
|
|
574
738
|
const tokenData = maybeData?.tokenData || maybeData || {};
|
|
575
739
|
const newRefreshToken = tokenData?.refreshToken;
|
|
@@ -587,7 +751,7 @@ async function getAuthRefreshToken(refreshToken) {
|
|
|
587
751
|
setRefreshToken(newRefreshToken, rExpires);
|
|
588
752
|
}
|
|
589
753
|
if (typeof token === "string") {
|
|
590
|
-
|
|
754
|
+
storAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
|
|
591
755
|
return { token, success: true };
|
|
592
756
|
}
|
|
593
757
|
return { token: null, success: false };
|
|
@@ -1538,6 +1702,8 @@ var authenticationClient = {
|
|
|
1538
1702
|
},
|
|
1539
1703
|
verifyOtp: (data) => mfaClient.verifyOtp(data),
|
|
1540
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),
|
|
1541
1707
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
1542
1708
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
1543
1709
|
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
@@ -2288,6 +2454,6 @@ function createMutation(mutationFn, options) {
|
|
|
2288
2454
|
};
|
|
2289
2455
|
}
|
|
2290
2456
|
|
|
2291
|
-
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 };
|
|
2292
|
-
//# sourceMappingURL=chunk-
|
|
2293
|
-
//# sourceMappingURL=chunk-
|
|
2457
|
+
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 };
|
|
2458
|
+
//# sourceMappingURL=chunk-GDMFRKAK.js.map
|
|
2459
|
+
//# sourceMappingURL=chunk-GDMFRKAK.js.map
|