woodsportal-client-sdk 4.0.7 → 4.0.8-dev.1

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 (72) hide show
  1. package/README.md +26 -0
  2. package/dist/adapters/angular/index.js +8 -6
  3. package/dist/adapters/angular/index.js.map +1 -1
  4. package/dist/adapters/native/index.d.ts +3 -0
  5. package/dist/adapters/native/index.js +11 -0
  6. package/dist/adapters/native/index.js.map +1 -0
  7. package/dist/adapters/react/index.d.ts +1 -1
  8. package/dist/adapters/react/index.js +9 -19
  9. package/dist/adapters/react/index.js.map +1 -1
  10. package/dist/adapters/vue/index.js +8 -6
  11. package/dist/adapters/vue/index.js.map +1 -1
  12. package/dist/auth-interceptor-policy-RGQ26NWR.js +6 -0
  13. package/dist/{auth-interceptor-policy-ACKZEQ6J.js.map → auth-interceptor-policy-RGQ26NWR.js.map} +1 -1
  14. package/dist/auth-utils-T4FIBK3O.js +7 -0
  15. package/dist/{auth-utils-CPO4LG4K.js.map → auth-utils-T4FIBK3O.js.map} +1 -1
  16. package/dist/{http-errors-CCCQECil.d.ts → build-error-description-XKI8vhGv.d.ts} +57 -6
  17. package/dist/{chunk-YZPW5F6U.js → chunk-5LISZE2R.js} +11 -7
  18. package/dist/chunk-5LISZE2R.js.map +1 -0
  19. package/dist/{chunk-BGUHACLT.js → chunk-AVMMEQLO.js} +3 -3
  20. package/dist/{chunk-BGUHACLT.js.map → chunk-AVMMEQLO.js.map} +1 -1
  21. package/dist/chunk-BXKFJ5NQ.js +1272 -0
  22. package/dist/chunk-BXKFJ5NQ.js.map +1 -0
  23. package/dist/chunk-DB6W3CJT.js +73 -0
  24. package/dist/chunk-DB6W3CJT.js.map +1 -0
  25. package/dist/{chunk-BKDJOWLW.js → chunk-ETYE73AH.js} +35 -8
  26. package/dist/chunk-ETYE73AH.js.map +1 -0
  27. package/dist/{chunk-ZQTCAG6K.js → chunk-JG3TEXWP.js} +7 -11
  28. package/dist/chunk-JG3TEXWP.js.map +1 -0
  29. package/dist/{chunk-WSUXZOHL.js → chunk-KPHAQNS2.js} +51 -6
  30. package/dist/chunk-KPHAQNS2.js.map +1 -0
  31. package/dist/{chunk-7J265W43.js → chunk-NDDE6ZZ3.js} +273 -87
  32. package/dist/chunk-NDDE6ZZ3.js.map +1 -0
  33. package/dist/{chunk-OAFDB4TJ.js → chunk-PVX6FWCW.js} +184 -104
  34. package/dist/chunk-PVX6FWCW.js.map +1 -0
  35. package/dist/{chunk-MO22VWRI.js → chunk-S3CVZTU4.js} +15 -9
  36. package/dist/chunk-S3CVZTU4.js.map +1 -0
  37. package/dist/{chunk-EFEBZBMU.js → chunk-UDAPRD7Z.js} +3 -2
  38. package/dist/chunk-UDAPRD7Z.js.map +1 -0
  39. package/dist/{chunk-TYJO2PSR.js → chunk-VN6VPM5C.js} +4 -4
  40. package/dist/{chunk-TYJO2PSR.js.map → chunk-VN6VPM5C.js.map} +1 -1
  41. package/dist/chunk-ZEGKRQA4.js +16 -0
  42. package/dist/chunk-ZEGKRQA4.js.map +1 -0
  43. package/dist/cross-tab-session-B34BLQU4.js +11 -0
  44. package/dist/{cross-tab-session-AGJVA2UZ.js.map → cross-tab-session-B34BLQU4.js.map} +1 -1
  45. package/dist/entries/auth.d.ts +4 -3
  46. package/dist/entries/auth.js +9 -8
  47. package/dist/entries/auth.js.map +1 -1
  48. package/dist/entries/crm.d.ts +3 -3
  49. package/dist/entries/crm.js +10 -9
  50. package/dist/entries/crm.js.map +1 -1
  51. package/dist/{index-Bh9eY8sA.d.ts → index-B-IGDI9L.d.ts} +11 -2
  52. package/dist/index.d.ts +45 -7
  53. package/dist/index.js +70 -17
  54. package/dist/index.js.map +1 -1
  55. package/dist/{pipeline-ui-DbEzI_v1.d.ts → pipeline-ui-COO9b3x2.d.ts} +2 -2
  56. package/dist/storage-migration-2PF52ZSB.js +4 -0
  57. package/dist/{storage-migration-CZTBKXQV.js.map → storage-migration-2PF52ZSB.js.map} +1 -1
  58. package/package.json +6 -1
  59. package/dist/auth-interceptor-policy-ACKZEQ6J.js +0 -5
  60. package/dist/auth-utils-CPO4LG4K.js +0 -5
  61. package/dist/chunk-7J265W43.js.map +0 -1
  62. package/dist/chunk-BKDJOWLW.js.map +0 -1
  63. package/dist/chunk-EFEBZBMU.js.map +0 -1
  64. package/dist/chunk-MO22VWRI.js.map +0 -1
  65. package/dist/chunk-OAFDB4TJ.js.map +0 -1
  66. package/dist/chunk-PK7GZY5P.js +0 -737
  67. package/dist/chunk-PK7GZY5P.js.map +0 -1
  68. package/dist/chunk-WSUXZOHL.js.map +0 -1
  69. package/dist/chunk-YZPW5F6U.js.map +0 -1
  70. package/dist/chunk-ZQTCAG6K.js.map +0 -1
  71. package/dist/cross-tab-session-AGJVA2UZ.js +0 -9
  72. package/dist/storage-migration-CZTBKXQV.js +0 -4
@@ -0,0 +1,1272 @@
1
+ import { getAuthRefreshToken, createMutation, Client } from './chunk-PVX6FWCW.js';
2
+ import { getParam, actions6 } from './chunk-ETYE73AH.js';
3
+ import { hasRefreshSession, isAccessTokenExpired, hydrateSessionRefreshState, clearSessionRefreshExhaustedState, resetSessionAuthState, isRefreshInFlight, isSessionRefreshExhausted, didLastRefreshFail, hasValidAccessToken, isExpiresAccessToken, isAuthenticateApp, isAuthenticated, clearAccessToken, setAccessToken, getAccessToken, refreshSession, getRefreshToken, classifyHttpError, clearRefreshToken, storeMfaPendingAccessToken, logger, setPortal, setSubscriptionType, setRefreshToken, setLoggedInDetails, setConfig, clearMfaPendingAccessToken } from './chunk-NDDE6ZZ3.js';
4
+ import { isCookieExpired, clearClientAuthCookies } from './chunk-KPHAQNS2.js';
5
+ import { parseApiErrorPayload } from './chunk-COHBSTHF.js';
6
+ import axios from 'axios';
7
+
8
+ // src/main/core/auth/session-contract.ts
9
+ function hasValidAccess(input) {
10
+ return input.hasAccessToken() && !input.isAccessTokenExpired();
11
+ }
12
+ function isFullyAuthenticated(input) {
13
+ if (input.isMfaPending?.()) {
14
+ return false;
15
+ }
16
+ if (hasValidAccess(input)) {
17
+ return true;
18
+ }
19
+ return input.hasRefreshSession();
20
+ }
21
+ function isMfaPendingSession(input) {
22
+ return Boolean(input.isMfaPending?.());
23
+ }
24
+ function hasAuthenticatedAccess(input) {
25
+ if (input.isMfaPending?.()) {
26
+ return Boolean(input.hasAccessToken());
27
+ }
28
+ return hasValidAccess(input);
29
+ }
30
+
31
+ // src/main/core/http/session-persistence-error.ts
32
+ var SessionPersistenceError = class extends Error {
33
+ constructor(message) {
34
+ super(message);
35
+ this.name = "SessionPersistenceError";
36
+ }
37
+ };
38
+
39
+ // src/main/core/http/login-session.ts
40
+ function unwrapLoginBody(response) {
41
+ return response?.data ?? response ?? {};
42
+ }
43
+ async function completeLoginSession(response) {
44
+ const body = unwrapLoginBody(response);
45
+ const tokenData = body?.tokenData || {};
46
+ const loggedInDetails = body?.loggedInDetails || {};
47
+ const currentPortal = loggedInDetails?.currentPortal || {};
48
+ const currentPortalId = currentPortal?.portalId || null;
49
+ const subscriptionType = loggedInDetails?.subscriptionType || "BASIC";
50
+ const token = tokenData?.token;
51
+ const refreshToken = tokenData?.refreshToken;
52
+ const expiresIn = tokenData?.expiresIn;
53
+ const refreshExpiresAt = tokenData?.refreshExpiresAt;
54
+ const rExpiresIn = tokenData?.refreshExpiresIn;
55
+ if (!token || typeof token !== "string") {
56
+ logger.error("auth", "login session missing access token", { operation: "completeLoginSession" });
57
+ throw new SessionPersistenceError("Session persistence failed: missing access token in login response");
58
+ }
59
+ if (!refreshToken || typeof refreshToken !== "string") {
60
+ logger.error("auth", "login session missing refresh token", { operation: "completeLoginSession" });
61
+ throw new SessionPersistenceError("Session persistence failed: missing refresh token in login response");
62
+ }
63
+ await setPortal(currentPortal);
64
+ await setSubscriptionType(subscriptionType);
65
+ await setAccessToken(token, expiresIn);
66
+ await setRefreshToken(refreshToken, refreshExpiresAt ?? rExpiresIn);
67
+ await setLoggedInDetails(body);
68
+ actions6.setProfile(response?.data != null ? response : { data: body });
69
+ setConfig.setDevPortalId(currentPortalId);
70
+ clearMfaPendingAccessToken("c");
71
+ return response;
72
+ }
73
+ async function applyLoginResponse(response) {
74
+ const data = unwrapLoginBody(response);
75
+ if (data?.twoFactorRequired === true) {
76
+ const tokenData = data?.tokenData || {};
77
+ const token = tokenData?.token;
78
+ const expiresIn = tokenData?.expiresIn;
79
+ if (token) {
80
+ clearRefreshToken();
81
+ await setAccessToken(token, expiresIn);
82
+ storeMfaPendingAccessToken(token, expiresIn, "c");
83
+ }
84
+ return response;
85
+ }
86
+ return completeLoginSession(response);
87
+ }
88
+
89
+ // src/main/features/auth/api/authentication.ts
90
+ function preLogin(options) {
91
+ const { mutate, isLoading } = createMutation(async (payload) => {
92
+ const response = await Client.authentication.preLogin(payload);
93
+ return response;
94
+ }, options);
95
+ return {
96
+ mutate,
97
+ preLogin: mutate,
98
+ isLoading
99
+ };
100
+ }
101
+ function login(options) {
102
+ const { mutate, isLoading } = createMutation(async (payload) => {
103
+ const response = await Client.authentication.login(payload);
104
+ await applyLoginResponse(response);
105
+ return response;
106
+ }, options);
107
+ return {
108
+ mutate,
109
+ login: mutate,
110
+ isLoading
111
+ };
112
+ }
113
+ function handoff(options) {
114
+ const { mutate, isLoading } = createMutation(async (payload) => {
115
+ const response = await Client.authentication.handoff(payload);
116
+ await applyLoginResponse(response);
117
+ return response;
118
+ }, options);
119
+ return {
120
+ mutate,
121
+ handoff: mutate,
122
+ isLoading
123
+ };
124
+ }
125
+ function clientSession(options) {
126
+ const { mutate, isLoading } = createMutation(async (payload) => {
127
+ const response = await Client.authentication.clientSession(payload);
128
+ await applyLoginResponse(response);
129
+ return response;
130
+ }, options);
131
+ return {
132
+ mutate,
133
+ clientSession: mutate,
134
+ isLoading
135
+ };
136
+ }
137
+ function register(options) {
138
+ const { mutate, isLoading } = createMutation(async (payload) => {
139
+ const response = await Client.authentication.register(payload);
140
+ return response;
141
+ }, options);
142
+ return {
143
+ mutate,
144
+ register: mutate,
145
+ isLoading
146
+ };
147
+ }
148
+ function verifyEmail(options) {
149
+ const { mutate, isLoading } = createMutation(async (payload) => {
150
+ const verifyEmailPayload = payload || {};
151
+ const token = getParam("token");
152
+ if (!verifyEmailPayload?.token) verifyEmailPayload.token = token;
153
+ const response = await Client.authentication.verifyEmail(verifyEmailPayload);
154
+ return response;
155
+ }, options);
156
+ return {
157
+ mutate,
158
+ verifyEmail: mutate,
159
+ isLoading
160
+ };
161
+ }
162
+ function resetPasswordVerifyToken(options) {
163
+ const { mutate, isLoading } = createMutation(async (payload) => {
164
+ const resetPasswordVerifyTokenPayload = payload || {};
165
+ const token = getParam("token");
166
+ if (!resetPasswordVerifyTokenPayload?.token) resetPasswordVerifyTokenPayload.token = token;
167
+ const response = await Client.authentication.resetPasswordVerifyToken(resetPasswordVerifyTokenPayload);
168
+ return response;
169
+ }, options);
170
+ return {
171
+ mutate,
172
+ resetPasswordVerifyToken: mutate,
173
+ isLoading
174
+ };
175
+ }
176
+ function resetPassword(options) {
177
+ const { mutate, isLoading } = createMutation(async (payload) => {
178
+ const response = await Client.authentication.resetPassword(payload);
179
+ return response;
180
+ }, options);
181
+ return {
182
+ mutate,
183
+ resetPassword: mutate,
184
+ isLoading
185
+ };
186
+ }
187
+ function forgetPassword(options) {
188
+ const { mutate, isLoading } = createMutation(async (payload) => {
189
+ const response = await Client.authentication.forgetPassword(payload);
190
+ return response;
191
+ }, options);
192
+ return {
193
+ mutate,
194
+ forgetPassword: mutate,
195
+ isLoading
196
+ };
197
+ }
198
+ function verifyForgotPasswordOtp(options) {
199
+ const { mutate, isLoading } = createMutation(async (payload) => {
200
+ const response = await Client.authentication.verifyForgotPasswordOtp(payload);
201
+ const data = response?.data ?? response;
202
+ return {
203
+ token: data?.token ?? ""
204
+ };
205
+ }, options);
206
+ return {
207
+ mutate,
208
+ verifyForgotPasswordOtp: mutate,
209
+ isLoading
210
+ };
211
+ }
212
+ function logout(options) {
213
+ const { mutate, isLoading } = createMutation(async () => {
214
+ try {
215
+ const response = await Client.authentication.logout();
216
+ return response;
217
+ } finally {
218
+ clearAccessToken();
219
+ clearClientAuthCookies();
220
+ }
221
+ }, options);
222
+ return {
223
+ mutate,
224
+ logout: mutate,
225
+ isLoading
226
+ };
227
+ }
228
+ function registerExistingUser(options) {
229
+ const { mutate, isLoading } = createMutation(async (payload) => {
230
+ const response = await Client.authentication.registerExistingUser(payload);
231
+ return response;
232
+ }, options);
233
+ return {
234
+ mutate,
235
+ registerExistingUser: mutate,
236
+ isLoading
237
+ };
238
+ }
239
+ function verifyEmailResend(options) {
240
+ const { mutate, isLoading } = createMutation(async (payload) => {
241
+ const response = await Client.authentication.verifyEmailResend(payload);
242
+ return response;
243
+ }, options);
244
+ return {
245
+ mutate,
246
+ verifyEmailResend: mutate,
247
+ isLoading
248
+ };
249
+ }
250
+ function resendEmail(options) {
251
+ const { mutate, isLoading } = createMutation(async (payload) => {
252
+ const response = await Client.authentication.resendEmail(payload);
253
+ return response;
254
+ }, options);
255
+ return {
256
+ mutate,
257
+ resendEmail: mutate,
258
+ isLoading
259
+ };
260
+ }
261
+
262
+ // src/main/features/auth/api/mfa.ts
263
+ function verifyOtp(options) {
264
+ const { mutate, isLoading } = createMutation(async (payload) => {
265
+ const response = await Client.authentication.verifyOtp(payload);
266
+ await applyLoginResponse(response);
267
+ return response;
268
+ }, options);
269
+ return { mutate, verifyOtp: mutate, isLoading };
270
+ }
271
+ function sendMfaOtp(options) {
272
+ const { mutate, isLoading } = createMutation(
273
+ async (payload) => Client.mfa.sendPendingOtp(payload),
274
+ options
275
+ );
276
+ return { mutate, sendOtp: mutate, sendMfaOtp: mutate, isLoading };
277
+ }
278
+ function pendingPasskeyOptions(options) {
279
+ const { mutate, isLoading } = createMutation(
280
+ async (payload) => Client.mfa.pendingPasskeyOptions(payload),
281
+ options
282
+ );
283
+ return { mutate, pendingPasskeyOptions: mutate, isLoading };
284
+ }
285
+ function pendingPasskeyVerify(options) {
286
+ const { mutate, isLoading } = createMutation(
287
+ async (payload) => {
288
+ const response = await Client.mfa.pendingPasskeyVerify(payload);
289
+ await applyLoginResponse(response);
290
+ return response;
291
+ },
292
+ options
293
+ );
294
+ return { mutate, pendingPasskeyVerify: mutate, isLoading };
295
+ }
296
+ function getMfaStatus(options) {
297
+ const { mutate, isLoading } = createMutation(
298
+ async (payload) => await Client.mfa.getStatus(payload),
299
+ options
300
+ );
301
+ return { mutate, getStatus: mutate, getMfaStatus: mutate, isLoading };
302
+ }
303
+ function setMfaPreferences(options) {
304
+ const { mutate, isLoading } = createMutation(
305
+ async (payload) => {
306
+ const { portalId, ...data } = payload;
307
+ return Client.mfa.setPreferences(data, { portalId });
308
+ },
309
+ options
310
+ );
311
+ return { mutate, setPreferences: mutate, setMfaPreferences: mutate, isLoading };
312
+ }
313
+ function startPhoneVerify(options) {
314
+ const { mutate, isLoading } = createMutation(async (payload) => {
315
+ const { portalId, ...data } = payload ?? { phone: "" };
316
+ return Client.mfa.startPhoneVerify(data, portalId != null ? { portalId } : void 0);
317
+ }, options);
318
+ return { mutate, startPhoneVerify: mutate, isLoading };
319
+ }
320
+ function confirmPhoneVerify(options) {
321
+ const { mutate, isLoading } = createMutation(async (payload) => {
322
+ const { portalId, ...data } = payload ?? { phone: "", code: "" };
323
+ return Client.mfa.confirmPhoneVerify(data, portalId != null ? { portalId } : void 0);
324
+ }, options);
325
+ return { mutate, confirmPhoneVerify: mutate, isLoading };
326
+ }
327
+ function totpEnrollStart(options) {
328
+ const { mutate, isLoading } = createMutation(async (payload) => Client.mfa.totpEnrollStart(payload), options);
329
+ return { mutate, totpEnrollStart: mutate, isLoading };
330
+ }
331
+ function totpEnrollVerify(options) {
332
+ const { mutate, isLoading } = createMutation(
333
+ async (payload) => Client.mfa.totpEnrollVerify(payload),
334
+ options
335
+ );
336
+ return { mutate, totpEnrollVerify: mutate, isLoading };
337
+ }
338
+ function totpDisable(options) {
339
+ const { mutate, isLoading } = createMutation(async (payload) => {
340
+ const { portalId, ...data } = payload;
341
+ return Client.mfa.totpDisable(data, { portalId });
342
+ }, options);
343
+ return { mutate, totpDisable: mutate, isLoading };
344
+ }
345
+ function phoneUnverify(options) {
346
+ const { mutate, isLoading } = createMutation(
347
+ async (payload) => {
348
+ const { portalId, ...data } = payload;
349
+ return Client.mfa.phoneUnverify(data, { portalId });
350
+ },
351
+ options
352
+ );
353
+ return { mutate, phoneUnverify: mutate, isLoading };
354
+ }
355
+ function backupCodesRegenerate(options) {
356
+ const { mutate, isLoading } = createMutation(
357
+ async (payload) => {
358
+ const { portalId, ...data } = payload;
359
+ return Client.mfa.backupCodesRegenerate(data, { portalId });
360
+ },
361
+ options
362
+ );
363
+ return { mutate, backupCodesRegenerate: mutate, isLoading };
364
+ }
365
+ function mfaOptOut(options) {
366
+ const { mutate, isLoading } = createMutation(async (payload) => {
367
+ const { portalId, ...data } = payload;
368
+ return Client.mfa.optOut(data, { portalId });
369
+ }, options);
370
+ return { mutate, optOut: mutate, mfaOptOut: mutate, isLoading };
371
+ }
372
+ function webauthnRegisterOptions(options) {
373
+ const { mutate, isLoading } = createMutation(
374
+ async (payload) => Client.mfa.webauthnRegisterOptions(payload),
375
+ options
376
+ );
377
+ return { mutate, webauthnRegisterOptions: mutate, isLoading };
378
+ }
379
+ function webauthnRegisterVerify(options) {
380
+ const { mutate, isLoading } = createMutation(
381
+ async (payload) => Client.mfa.webauthnRegisterVerify(payload),
382
+ options
383
+ );
384
+ return { mutate, webauthnRegisterVerify: mutate, isLoading };
385
+ }
386
+ function webauthnAuthOptions(options) {
387
+ const { mutate, isLoading } = createMutation(async (payload) => Client.mfa.webauthnAuthOptions(payload), options);
388
+ return { mutate, webauthnAuthOptions: mutate, isLoading };
389
+ }
390
+ function webauthnAuthVerify(options) {
391
+ const { mutate, isLoading } = createMutation(
392
+ async (payload) => Client.mfa.webauthnAuthVerify(payload),
393
+ options
394
+ );
395
+ return { mutate, webauthnAuthVerify: mutate, isLoading };
396
+ }
397
+ function listWebauthnCredentials(options) {
398
+ const { mutate, isLoading } = createMutation(
399
+ async (payload) => Client.mfa.listWebauthnCredentials(payload),
400
+ options
401
+ );
402
+ return { mutate, listWebauthnCredentials: mutate, isLoading };
403
+ }
404
+ function deleteWebauthnCredential(options) {
405
+ const { mutate, isLoading } = createMutation(
406
+ async (payload) => {
407
+ const { credentialRecordId, portalId } = payload;
408
+ return Client.mfa.deleteWebauthnCredential(credentialRecordId, { portalId });
409
+ },
410
+ options
411
+ );
412
+ return { mutate, deleteWebauthnCredential: mutate, isLoading };
413
+ }
414
+ function passkeyLoginOptions(options) {
415
+ const { mutate, isLoading } = createMutation(
416
+ async (payload) => Client.mfa.passkeyLoginOptions(payload),
417
+ options
418
+ );
419
+ return { mutate, passkeyLoginOptions: mutate, isLoading };
420
+ }
421
+ function passkeyLoginVerify(options) {
422
+ const { mutate, isLoading } = createMutation(async (payload) => {
423
+ const response = await Client.mfa.passkeyLoginVerify(payload);
424
+ await applyLoginResponse(response);
425
+ return response;
426
+ }, options);
427
+ return { mutate, passkeyLoginVerify: mutate, isLoading };
428
+ }
429
+
430
+ // src/main/features/auth/api/security.ts
431
+ function getSecurityOverview(options) {
432
+ const { mutate, isLoading } = createMutation(
433
+ async (payload) => Client.security.getOverview(payload),
434
+ options
435
+ );
436
+ return { mutate, getOverview: mutate, getSecurityOverview: mutate, isLoading };
437
+ }
438
+ function getSecurityLoginActivity(options) {
439
+ const { mutate, isLoading } = createMutation(
440
+ async (payload) => Client.security.getLoginActivity(payload),
441
+ options
442
+ );
443
+ return { mutate, getLoginActivity: mutate, getSecurityLoginActivity: mutate, isLoading };
444
+ }
445
+ function getSecuritySessions(options) {
446
+ const { mutate, isLoading } = createMutation(
447
+ async (payload) => Client.security.getSessions(payload),
448
+ options
449
+ );
450
+ return { mutate, getSessions: mutate, getSecuritySessions: mutate, isLoading };
451
+ }
452
+ function revokeSecuritySession(options) {
453
+ const { mutate, isLoading } = createMutation(
454
+ async (payload) => Client.security.revokeSession(payload),
455
+ options
456
+ );
457
+ return { mutate, revokeSession: mutate, revokeSecuritySession: mutate, isLoading };
458
+ }
459
+ function revokeOtherSecuritySessions(options) {
460
+ const { mutate, isLoading } = createMutation(
461
+ async (payload) => Client.security.revokeOtherSessions(payload?.refreshToken),
462
+ options
463
+ );
464
+ return { mutate, revokeOtherSessions: mutate, revokeOtherSecuritySessions: mutate, isLoading };
465
+ }
466
+
467
+ // src/main/features/auth/api/login-bootstrap.ts
468
+ function getLoginBootstrap(options) {
469
+ const { mutate, isLoading } = createMutation(async (payload) => {
470
+ const response = await Client.authentication.getLoginBootstrap(payload);
471
+ return response;
472
+ }, options);
473
+ return {
474
+ mutate,
475
+ getLoginBootstrap: mutate,
476
+ isLoading
477
+ };
478
+ }
479
+
480
+ // src/main/features/auth/api/sso.ts
481
+ function getSsoDetails(options) {
482
+ const { mutate, isLoading } = createMutation(async () => {
483
+ const response = await Client.sso.getSsoDetails();
484
+ return response;
485
+ }, options);
486
+ return {
487
+ mutate,
488
+ getDetails: mutate,
489
+ getSsoDetails: mutate,
490
+ isLoading
491
+ };
492
+ }
493
+ function generateSsoUrl(options) {
494
+ const { mutate, isLoading } = createMutation(async (payload) => {
495
+ const response = await Client.sso.generateSsoUrl(payload);
496
+ return response;
497
+ }, options);
498
+ return {
499
+ mutate,
500
+ generateUrl: mutate,
501
+ generateSsoUrl: mutate,
502
+ isLoading
503
+ };
504
+ }
505
+ function ssoCallback(options) {
506
+ const { mutate, isLoading } = createMutation(async (payload) => {
507
+ const response = await Client.sso.ssoCallback(payload);
508
+ await applyLoginResponse(response);
509
+ return response;
510
+ }, options);
511
+ return {
512
+ mutate,
513
+ callback: mutate,
514
+ ssoCallback: mutate,
515
+ isLoading
516
+ };
517
+ }
518
+
519
+ // src/main/features/auth/api/users.ts
520
+ var meRequestInFlight = null;
521
+ async function fetchMeOnce() {
522
+ if (!meRequestInFlight) {
523
+ meRequestInFlight = Client.user.me().finally(() => {
524
+ meRequestInFlight = null;
525
+ });
526
+ }
527
+ return meRequestInFlight;
528
+ }
529
+ function me(options) {
530
+ const { mutate, isLoading } = createMutation(async () => {
531
+ const response = await fetchMeOnce();
532
+ actions6.setProfile(response);
533
+ return response?.data;
534
+ }, options);
535
+ return {
536
+ mutate,
537
+ me: mutate,
538
+ isLoading
539
+ };
540
+ }
541
+ function profile(options) {
542
+ const { mutate, isLoading } = createMutation(async (paylaod) => {
543
+ const response = await Client.user.profile(paylaod);
544
+ return response;
545
+ }, options);
546
+ return {
547
+ mutate,
548
+ profile: mutate,
549
+ isLoading
550
+ };
551
+ }
552
+ function profileUpdate(options) {
553
+ const { mutate, isLoading } = createMutation(async (paylaod) => {
554
+ const response = await Client.user.profileUpdate(paylaod);
555
+ return response;
556
+ }, options);
557
+ return {
558
+ mutate,
559
+ updateProfile: mutate,
560
+ profileUpdate: mutate,
561
+ isLoading
562
+ };
563
+ }
564
+ function changePassword(options) {
565
+ const { mutate, isLoading } = createMutation(async (payload) => {
566
+ const response = await Client.user.changePassword(payload);
567
+ return response;
568
+ }, options);
569
+ return {
570
+ mutate,
571
+ changePassword: mutate,
572
+ isLoading
573
+ };
574
+ }
575
+
576
+ // src/main/api/nested-auth-api.ts
577
+ var authApi = {
578
+ preLogin,
579
+ login,
580
+ clientSession,
581
+ handoff,
582
+ logout,
583
+ register,
584
+ verifyEmail,
585
+ registerExistingUser,
586
+ forgetPassword,
587
+ verifyForgotPasswordOtp,
588
+ resetPassword,
589
+ resetPasswordVerifyToken,
590
+ verifyEmailResend,
591
+ resendEmail,
592
+ changePassword,
593
+ me,
594
+ profile,
595
+ updateProfile: profileUpdate,
596
+ mfa: {
597
+ verifyOtp,
598
+ sendOtp: sendMfaOtp,
599
+ pendingPasskeyOptions,
600
+ pendingPasskeyVerify,
601
+ getStatus: getMfaStatus,
602
+ setPreferences: setMfaPreferences,
603
+ startPhoneVerify,
604
+ confirmPhoneVerify,
605
+ totpEnrollStart,
606
+ totpEnrollVerify,
607
+ totpDisable,
608
+ phoneUnverify,
609
+ backupCodesRegenerate,
610
+ optOut: mfaOptOut,
611
+ mfaOptOut,
612
+ webauthnRegisterOptions,
613
+ webauthnRegisterVerify,
614
+ webauthnAuthOptions,
615
+ webauthnAuthVerify,
616
+ listWebauthnCredentials,
617
+ deleteWebauthnCredential,
618
+ passkeyLoginOptions,
619
+ passkeyLoginVerify
620
+ },
621
+ security: {
622
+ getOverview: getSecurityOverview,
623
+ getLoginActivity: getSecurityLoginActivity,
624
+ getSessions: getSecuritySessions,
625
+ revokeSession: revokeSecuritySession,
626
+ revokeOtherSessions: revokeOtherSecuritySessions
627
+ },
628
+ loginBootstrap: getLoginBootstrap,
629
+ sso: {
630
+ getDetails: getSsoDetails,
631
+ generateUrl: generateSsoUrl,
632
+ callback: ssoCallback
633
+ },
634
+ session: {
635
+ getRefreshToken,
636
+ refreshSession,
637
+ refreshAccessToken: getAuthRefreshToken,
638
+ getAccessToken,
639
+ setAccessToken,
640
+ clearAccessToken,
641
+ isAuthenticated,
642
+ isAuthenticateApp,
643
+ isAccessTokenExpired,
644
+ isExpiresAccessToken,
645
+ isCookieExpired,
646
+ hasRefreshSession,
647
+ hasValidAccessToken,
648
+ didLastRefreshFail,
649
+ isSessionRefreshExhausted,
650
+ isRefreshInFlight,
651
+ resetSessionAuthState,
652
+ clearSessionRefreshExhaustedState,
653
+ hydrateSessionRefreshState,
654
+ contract: () => ({
655
+ hasAccessToken: () => Boolean(getAccessToken()),
656
+ isAccessTokenExpired,
657
+ hasRefreshSession
658
+ }),
659
+ isFullyAuthenticated: () => isFullyAuthenticated({
660
+ hasAccessToken: () => Boolean(getAccessToken()),
661
+ isAccessTokenExpired,
662
+ hasRefreshSession
663
+ }),
664
+ hasAuthenticatedAccess: () => hasAuthenticatedAccess({
665
+ hasAccessToken: () => Boolean(getAccessToken()),
666
+ isAccessTokenExpired,
667
+ hasRefreshSession
668
+ }),
669
+ hasValidAccess: () => hasValidAccess({
670
+ hasAccessToken: () => Boolean(getAccessToken()),
671
+ isAccessTokenExpired,
672
+ hasRefreshSession
673
+ })
674
+ }
675
+ };
676
+
677
+ // src/main/core/auth/bootstrap-contract.ts
678
+ async function recoverMfaGateOnBoot(input) {
679
+ const hasContext = input.hasMfaContext();
680
+ let hasToken = input.hasAccessToken();
681
+ const hasRefresh = input.hasRefreshToken();
682
+ if (hasContext && hasToken) {
683
+ return "pending";
684
+ }
685
+ if (hasContext && !hasToken) {
686
+ const hydrated = await input.tryHydrateMfaAccessToken?.();
687
+ hasToken = input.hasAccessToken();
688
+ if (hydrated && hasToken) {
689
+ return "pending";
690
+ }
691
+ input.clearMfaOrphan();
692
+ return "orphan_cleared";
693
+ }
694
+ if (hasToken && !hasContext && !hasRefresh) {
695
+ input.clearStaleAccessToken();
696
+ return "stale_token_cleared";
697
+ }
698
+ return "none";
699
+ }
700
+
701
+ // src/main/core/auth/route-guard-contract.ts
702
+ function resolveAuthRouteAction(input) {
703
+ const {
704
+ pathname,
705
+ isPublicAuthRoute,
706
+ session,
707
+ funnel,
708
+ mfaRoute,
709
+ previewMode = false,
710
+ sessionRestoring = false,
711
+ sessionRefreshExhausted = false
712
+ } = input;
713
+ if (previewMode) {
714
+ return { kind: "allow" };
715
+ }
716
+ if (isMfaPendingSession(session)) {
717
+ if (pathname === mfaRoute) {
718
+ return { kind: "allow" };
719
+ }
720
+ return { kind: "redirect_mfa" };
721
+ }
722
+ if (sessionRestoring && !sessionRefreshExhausted) {
723
+ return { kind: "show_loader" };
724
+ }
725
+ if (sessionRefreshExhausted && !hasValidAccess(session)) {
726
+ if (isPublicAuthRoute(pathname)) {
727
+ return { kind: "allow" };
728
+ }
729
+ return { kind: "redirect_login" };
730
+ }
731
+ const authenticated = isFullyAuthenticated(session);
732
+ if (!authenticated) {
733
+ if (isPublicAuthRoute(pathname)) {
734
+ return { kind: "allow" };
735
+ }
736
+ return { kind: "redirect_login" };
737
+ }
738
+ if (funnel) {
739
+ if (funnel.emailVerified === false) {
740
+ return { kind: "redirect_funnel", step: "email_verify" };
741
+ }
742
+ if (!funnel.hubId) {
743
+ return { kind: "redirect_funnel", step: "hub_select" };
744
+ }
745
+ if (!funnel.portalId) {
746
+ return { kind: "redirect_funnel", step: "portal_select" };
747
+ }
748
+ }
749
+ return { kind: "allow" };
750
+ }
751
+
752
+ // src/main/core/errors/api-error-active-codes.ts
753
+ var WOODSPORTAL_API_ACTIVE_ERROR_CODES = [
754
+ "ACCESS_DENIED",
755
+ "ACCESS_FORBIDDEN",
756
+ "ACTION_NOT_ACCESSIBLE",
757
+ "AMBIGUOUS_HUB_ID",
758
+ "API_EXCEPTION",
759
+ "ASSOCIATION_LABEL_NOT_FOUND",
760
+ "AUTHENTICATION_FAILED",
761
+ "AUTH_ACCOUNT_LOCKED",
762
+ "AUTH_TOKEN_EXPIRED",
763
+ "AUTH_TOKEN_INVALID",
764
+ "BAD_REQUEST",
765
+ "COMMERCIAL_ACCESS_EXPIRED",
766
+ "DATA_CONFLICT",
767
+ "DATA_FETCH_FAILED",
768
+ "DATA_PROCESSING_FAILED",
769
+ "DECRYPTION_FAILED",
770
+ "EMAIL_SENDING_FAILED",
771
+ "ENCRYPTION_FAILED",
772
+ "ENTITLEMENT_USAGE_EXCEEDED",
773
+ "EXTERNAL_API_CLIENT_ERROR",
774
+ "FILE_UNSUPPORTED_TYPE",
775
+ "FILE_UPLOAD_FAILED",
776
+ "GRAPHQL_API_EXCEPTION",
777
+ "HUBSPOT_OBJECT_NOT_FOUND",
778
+ "HUBSPOT_REAUTH_REQUIRED",
779
+ "HUBSPOT_SYNC_FAILED",
780
+ "ILLEGAL_STATE",
781
+ "INTERNAL_ERROR",
782
+ "INVALID_ARGUMENT",
783
+ "JSON_PARSE_FAILED",
784
+ "JWT_SECRET_INVALID",
785
+ "LAST_ACTIVE_PIPELINE_REQUIRED",
786
+ "LOGIN_FAILED",
787
+ "MALFORMED_JSON",
788
+ "METHOD_NOT_ALLOWED",
789
+ "MISSING_HEADERS",
790
+ "MISSING_REFRESH_TOKEN",
791
+ "MISSING_REQUIRED_DATA",
792
+ "OAUTH_PROCESSING_ERROR",
793
+ "OBJECT_ASSOCIATION_NOT_FOUND",
794
+ "OBJECT_INACTIVE",
795
+ "PORTAL_INACTIVE",
796
+ "PRIMARY_COMPANY_NOT_FOUND",
797
+ "PRODUCT_INSTALL_FAILED",
798
+ "RATE_LIMIT_EXCEEDED",
799
+ "RESOURCE_ALREADY_EXISTS",
800
+ "RESOURCE_CREATION_FAILED",
801
+ "RESOURCE_DELETION_FAILED",
802
+ "RESOURCE_MISSING_ASSOCIATION",
803
+ "RESOURCE_NOT_FOUND",
804
+ "RESOURCE_UPDATE_FAILED",
805
+ "RESOURCE_USER_NOT_FOUND",
806
+ "SQS_PROCESSING_FAILED",
807
+ "SUBSCRIPTION_ERROR",
808
+ "SYSTEM_INTERNAL_ERROR",
809
+ "TOO_MANY_REQUESTS",
810
+ "USERNAME_NOT_FOUND",
811
+ "VALIDATION_FAILED",
812
+ "WARM_FAILED"
813
+ ];
814
+
815
+ // src/main/core/errors/api-error-display-config.ts
816
+ function cfg(variant, title, fallbackDescription, options) {
817
+ return {
818
+ variant,
819
+ title,
820
+ fallbackDescription,
821
+ retry: options?.retry,
822
+ support: options?.support,
823
+ contentVariant: options?.contentVariant,
824
+ severity: options?.severity
825
+ };
826
+ }
827
+ var resource = (title, desc, options) => cfg("error", title, desc, { severity: "recoverable", ...options });
828
+ var association = (title, desc, options) => cfg("association", title, desc, {
829
+ severity: "informational",
830
+ contentVariant: "association-not-found",
831
+ retry: false,
832
+ ...options
833
+ });
834
+ var access = (title, desc, options) => cfg("access", title, desc, {
835
+ severity: "informational",
836
+ contentVariant: "no-permission",
837
+ retry: false,
838
+ ...options
839
+ });
840
+ var auth = (title, desc, options) => cfg("auth", title, desc, { severity: "auth", retry: false, ...options });
841
+ var validation = (title, desc, retry = false, options) => cfg("validation", title, desc, { severity: retry ? "recoverable" : "informational", retry, ...options });
842
+ var commercial = (title, desc, options) => cfg("commercial", title, desc, { severity: "informational", support: true, retry: false, ...options });
843
+ var file = (title, desc, retry = true, options) => cfg("file", title, desc, { severity: retry ? "recoverable" : "informational", retry, ...options });
844
+ var integration = (title, desc, retry = true, options) => cfg("integration", title, desc, { severity: retry ? "recoverable" : "informational", retry, ...options });
845
+ var system = (title, desc, retry = true, options) => cfg("error", title, desc, { severity: "recoverable", retry, support: true, ...options });
846
+ var rateLimit = (title, desc, options) => cfg("rateLimit", title, desc, { severity: "recoverable", retry: true, ...options });
847
+ var API_ERROR_DISPLAY_CONFIG = {
848
+ // Resource & data
849
+ RESOURCE_NOT_FOUND: resource(
850
+ "Resource not found",
851
+ "The requested resource could not be found. It may have been removed or you may not have access to it.",
852
+ { support: true }
853
+ ),
854
+ HUBSPOT_OBJECT_NOT_FOUND: resource(
855
+ "Configuration not found",
856
+ "HubSpot object configuration is missing for this portal or object type. Contact your administrator.",
857
+ { support: true, severity: "informational", retry: false, contentVariant: "association-not-found" }
858
+ ),
859
+ OBJECT_ASSOCIATION_NOT_FOUND: association("Association not found", "Association not found. Please contact your administrator or support team.", {
860
+ support: true
861
+ }),
862
+ ASSOCIATION_LABEL_NOT_FOUND: association(
863
+ "Association label not found",
864
+ "The association label could not be found. Contact your administrator to review the association setup.",
865
+ { support: true }
866
+ ),
867
+ PRIMARY_COMPANY_NOT_FOUND: association(
868
+ "Primary company not found",
869
+ "Primary company not found. Please contact your administrator or support team.",
870
+ { support: true }
871
+ ),
872
+ RESOURCE_USER_NOT_FOUND: resource("User not found", "The requested user could not be found.", { support: true }),
873
+ USERNAME_NOT_FOUND: resource("User not found", "Username lookup failed. Verify the username and try again."),
874
+ RESOURCE_ALREADY_EXISTS: resource("Resource already exists", "A resource with these details already exists."),
875
+ RESOURCE_MISSING_ASSOCIATION: association(
876
+ "Association required",
877
+ "A required association is missing. Create the association or contact your administrator.",
878
+ { support: true }
879
+ ),
880
+ RESOURCE_CREATION_FAILED: resource("Couldn't create resource", "We couldn't create this resource. Please try again.", { retry: true }),
881
+ RESOURCE_UPDATE_FAILED: resource("Couldn't update resource", "We couldn't update this resource. Please try again.", { retry: true }),
882
+ RESOURCE_DELETION_FAILED: resource("Couldn't delete resource", "We couldn't delete this resource. Please try again.", { retry: true }),
883
+ DATA_FETCH_FAILED: resource(
884
+ "Couldn't load this page",
885
+ "We couldn't load this page. Please try again in a few minutes. If the problem persists, contact your administrator.",
886
+ { retry: true, support: true }
887
+ ),
888
+ DATA_PROCESSING_FAILED: resource("Processing failed", "We couldn't process the data. Please try again in a few minutes.", { retry: true }),
889
+ DATA_CONFLICT: resource("Data conflict", "This action could not be completed because of a data conflict. Refresh and try again.", {
890
+ retry: true
891
+ }),
892
+ JSON_PARSE_FAILED: resource("Invalid data", "The response could not be read. Please try again.", { retry: true }),
893
+ OBJECT_INACTIVE: resource("Object inactive", "This HubSpot object is inactive. Contact your administrator to enable it.", { support: true }),
894
+ LAST_ACTIVE_PIPELINE_REQUIRED: resource("Pipeline required", "The last active pipeline cannot be disabled for deals or tickets.", {
895
+ support: true
896
+ }),
897
+ MISSING_REQUIRED_DATA: resource("Missing required data", "Required information is missing. Check the form and try again."),
898
+ // Auth & access
899
+ AUTHENTICATION_FAILED: auth("Authentication failed", "Sign-in failed. Check your credentials and try again."),
900
+ AUTH_TOKEN_INVALID: auth("Session invalid", "Your session is invalid. Please sign in again."),
901
+ AUTH_TOKEN_EXPIRED: auth("Session expired", "Your session has expired. Please sign in again."),
902
+ AUTH_ACCOUNT_LOCKED: auth("Account locked", "Your account is locked. Contact support if you need access."),
903
+ LOGIN_FAILED: auth("Login failed", "We could not sign you in. Check your credentials and try again."),
904
+ ACCESS_DENIED: access("Access denied", "You don't have access to this section yet. Contact your administrator to request permission."),
905
+ ACCESS_FORBIDDEN: access("Access forbidden", "You don't have permission to access this resource."),
906
+ MISSING_REFRESH_TOKEN: auth("Session ended", "Your session has ended. Please sign in again."),
907
+ MISSING_HEADERS: validation("Invalid request", "Required request headers are missing."),
908
+ JWT_SECRET_INVALID: system("Configuration error", "Authentication is misconfigured. Contact your administrator."),
909
+ OAUTH_PROCESSING_ERROR: auth("OAuth error", "We could not complete the OAuth sign-in. Please try again."),
910
+ HUBSPOT_REAUTH_REQUIRED: auth("HubSpot re-authorization required", "Reconnect your HubSpot account to continue using WoodsPortal."),
911
+ PORTAL_INACTIVE: auth("Portal inactive", "This portal is inactive. Contact your administrator."),
912
+ AMBIGUOUS_HUB_ID: auth("Account context unclear", "We could not determine which hub to use. Contact your administrator."),
913
+ // Validation & request
914
+ VALIDATION_FAILED: validation("Validation failed", "Please check the form and correct any errors."),
915
+ BAD_REQUEST: validation("Invalid request", "The request could not be processed. Check your input and try again."),
916
+ INVALID_ARGUMENT: validation("Invalid argument", "One or more values are invalid. Check your input and try again."),
917
+ MALFORMED_JSON: validation("Invalid request body", "The request body could not be read. Please try again."),
918
+ METHOD_NOT_ALLOWED: validation("Method not allowed", "This action is not supported for this endpoint."),
919
+ ACTION_NOT_ACCESSIBLE: cfg(
920
+ "actionDenied",
921
+ "Action not accessible",
922
+ "You don't have permission to perform this action. Contact your administrator to request access.",
923
+ {
924
+ severity: "informational",
925
+ contentVariant: "action-denied",
926
+ retry: false
927
+ }
928
+ ),
929
+ // Commercial & billing
930
+ COMMERCIAL_ACCESS_EXPIRED: commercial(
931
+ "Subscription required",
932
+ "Your trial or subscription has ended. Add a payment method or upgrade to continue."
933
+ ),
934
+ ENTITLEMENT_USAGE_EXCEEDED: commercial(
935
+ "Usage limit reached",
936
+ "You have exceeded your usage allowance. Upgrade your plan or contact your administrator."
937
+ ),
938
+ SUBSCRIPTION_ERROR: commercial("Subscription error", "There was a problem with your subscription. Contact your administrator or support."),
939
+ // Files
940
+ FILE_UPLOAD_FAILED: file("Upload failed", "We couldn't upload this file. Please try again."),
941
+ FILE_UNSUPPORTED_TYPE: file("Unsupported file type", "This file type is not supported. Choose a different file and try again.", false),
942
+ // External / integrations
943
+ EXTERNAL_API_CLIENT_ERROR: integration("External service error", "An external service returned an error. Please try again later."),
944
+ GRAPHQL_API_EXCEPTION: integration("CRM data error", "We could not load CRM data. Please try again in a few minutes."),
945
+ API_EXCEPTION: integration("Service error", "An external API call failed. Please try again."),
946
+ HUBSPOT_SYNC_FAILED: integration("HubSpot sync failed", "We could not sync with HubSpot. Please try again later."),
947
+ PRODUCT_INSTALL_FAILED: integration("Installation failed", "Product installation failed. Contact your administrator.", false),
948
+ SQS_PROCESSING_FAILED: system("Processing delayed", "Background processing failed. Please try again in a few minutes."),
949
+ EMAIL_SENDING_FAILED: integration("Email failed", "We could not send the email. Please try again."),
950
+ // System
951
+ INTERNAL_ERROR: system("Something went wrong", "An unexpected error occurred. Please try again."),
952
+ SYSTEM_INTERNAL_ERROR: system("Server error", "A server error occurred. Please try again in a few minutes."),
953
+ ILLEGAL_STATE: system("Unexpected state", "The application is in an unexpected state. Please try again."),
954
+ ENCRYPTION_FAILED: system("Security error", "Data could not be secured. Please try again."),
955
+ DECRYPTION_FAILED: system("Security error", "Data could not be read. Please try again."),
956
+ // Rate limiting
957
+ RATE_LIMIT_EXCEEDED: rateLimit("Too many requests", "You have made too many requests. Please wait a moment and try again."),
958
+ TOO_MANY_REQUESTS: rateLimit("Too many requests", "Too many requests from your network. Please wait and try again."),
959
+ // Internal job result
960
+ WARM_FAILED: cfg("error", "Cache warm failed", "A background cache operation failed.", { retry: true }),
961
+ // Reserved codes
962
+ ACCESS_UNAUTHORIZED: access("Unauthorized", "You are not authorized to access this resource."),
963
+ AUTH_2FA_REQUIRED: auth("Two-factor required", "Complete two-factor authentication to continue."),
964
+ AUTH_ACCOUNT_DISABLED: auth("Account disabled", "Your account is disabled. Contact support if you need access."),
965
+ AUTH_EMAIL_NOT_VERIFIED: auth("Email not verified", "Verify your email address before signing in."),
966
+ AUTH_INVALID_CREDENTIALS: auth("Invalid credentials", "The email or password is incorrect."),
967
+ CONFLICT_EMAIL_EXISTS: resource("Email already exists", "An account with this email already exists."),
968
+ CONFLICT_FILE_EXISTS: file("File already exists", "A file with this name already exists.", false),
969
+ CONFLICT_USERNAME_EXISTS: resource("Username taken", "This username is already in use."),
970
+ EXTERNAL_API_VALIDATION_ERROR: validation(
971
+ "External validation failed",
972
+ "An external service rejected the request. Check your input and try again."
973
+ ),
974
+ FILE_DECRYPTION_FAILED: file("File unreadable", "This file could not be decrypted or opened."),
975
+ RESOURCE_ACCESS_DENIED: access("Access denied", "You don't have permission to access this resource."),
976
+ RESOURCE_DEAL_NOT_FOUND: resource("Deal not found", "The requested deal could not be found.", { support: true }),
977
+ RESOURCE_DEPENDENCY_MISSING: resource("Dependency missing", "A required dependency is missing. Contact your administrator.", { support: true }),
978
+ RESOURCE_FILE_NOT_FOUND: file("File not found", "The requested file could not be found.", false),
979
+ RESOURCE_INVALID_STATE: resource("Invalid state", "This resource is in a state that does not allow this action.", { retry: true }),
980
+ RESOURCE_IN_USE: resource("Resource in use", "This resource is in use and cannot be modified right now. Try again later.", { retry: true }),
981
+ RESOURCE_MAPPING_NOT_DEFINED: resource("Mapping not defined", "Resource mapping is not configured. Contact your administrator.", {
982
+ support: true
983
+ }),
984
+ RESOURCE_PERMISSION_DENIED: access("Permission denied", "You don't have permission for this resource."),
985
+ RESOURCE_TYPE_MISMATCH: validation("Type mismatch", "The resource type does not match what was expected."),
986
+ SIGNATURE_INVALID: auth("Invalid signature", "Request signature validation failed."),
987
+ SYSTEM_DATABASE_ERROR: system("Database error", "A database error occurred. Please try again later."),
988
+ SYSTEM_DECRYPTION_ERROR: system("Security error", "Data could not be decrypted. Please try again."),
989
+ SYSTEM_ENCRYPTION_ERROR: system("Security error", "Data could not be encrypted. Please try again."),
990
+ SYSTEM_EXTERNAL_API_FAILURE: integration("External service unavailable", "An external service is unavailable. Please try again later."),
991
+ VALIDATION_INVALID_EMAIL: validation("Invalid email", "Enter a valid email address."),
992
+ VALIDATION_MISSING_FIELDS: validation("Missing fields", "Fill in all required fields."),
993
+ VALIDATION_PASSWORD_WEAK: validation("Weak password", "Choose a stronger password that meets the requirements."),
994
+ // workflow-action-api
995
+ COMMERCIAL_ACCESS_DENIED: commercial("Access denied", "Commercial access is required for this action. Contact your administrator."),
996
+ NOT_FOUND: resource("Not found", "The requested resource could not be found.", { support: true }),
997
+ UNEXPECTED_ERROR: system("Unexpected error", "An unexpected error occurred. Please try again."),
998
+ UNSUPPORTED_FILE_TYPE: file("Unsupported file type", "This file type is not supported. Choose a different file and try again.", false, {
999
+ contentVariant: "unsupported-file"
1000
+ }),
1001
+ VALIDATION_ERROR: validation("Validation error", "Please check the form and correct any errors.")
1002
+ };
1003
+ var API_ERROR_CATEGORY_FALLBACK = {
1004
+ AUTH: auth("Authentication required", "Please sign in to continue."),
1005
+ ACCESS: access("Access denied", "You don't have permission to access this resource."),
1006
+ ACCESS_ERROR: access("Access denied", "You don't have permission to access this resource."),
1007
+ VALIDATION: validation("Validation failed", "Please check your input and try again."),
1008
+ VALIDATION_ERROR: validation("Validation failed", "Please check your input and try again."),
1009
+ RATE_LIMIT: rateLimit("Too many requests", "Please wait a moment and try again."),
1010
+ FILE: file("File error", "There was a problem with the file. Please try again."),
1011
+ COMMERCIAL: commercial("Subscription required", "A subscription or upgrade is required for this action."),
1012
+ INTEGRATION: integration("Integration error", "An external service error occurred. Please try again."),
1013
+ THIRD_PARTY: integration("External service error", "An external service error occurred. Please try again."),
1014
+ EXTERNAL_API: integration("External service error", "An external service error occurred. Please try again."),
1015
+ RESOURCE: resource("Resource error", "There was a problem with this resource. Please try again.", { retry: true }),
1016
+ NOT_FOUND: resource("Not found", "The requested resource could not be found.", { support: true }),
1017
+ CONFLICT: resource("Conflict", "This action conflicts with existing data. Refresh and try again.", { retry: true }),
1018
+ INTERNAL: system("Server error", "A server error occurred. Please try again."),
1019
+ SYSTEM: system("Server error", "A server error occurred. Please try again."),
1020
+ GENERIC: system("Something went wrong", "Something went wrong. Please try again."),
1021
+ GENERAL: system("Something went wrong", "Something went wrong. Please try again."),
1022
+ GENERAL_ERROR: system("Something went wrong", "Something went wrong. Please try again.")
1023
+ };
1024
+ var DEFAULT_API_ERROR_DISPLAY = cfg("error", "Something went wrong", "Something went wrong. Please try again.", {
1025
+ retry: true
1026
+ });
1027
+ var NETWORK_ERROR_DISPLAY = cfg(
1028
+ "network",
1029
+ "Connection problem",
1030
+ "Unable to reach the server. Please check your connection and try again.",
1031
+ { retry: true }
1032
+ );
1033
+ var TIMEOUT_ERROR_DISPLAY = cfg(
1034
+ "network",
1035
+ "Request timed out",
1036
+ "The request timed out. Please check your connection and try again.",
1037
+ { retry: true }
1038
+ );
1039
+ var SERVICE_UNAVAILABLE_DISPLAY = cfg(
1040
+ "network",
1041
+ "Service unavailable",
1042
+ "Service temporarily unavailable. Please try again in a few minutes.",
1043
+ { retry: true }
1044
+ );
1045
+
1046
+ // src/main/core/errors/build-error-description.ts
1047
+ var DETAILED_MESSAGE_ERROR_CODES = /* @__PURE__ */ new Set([
1048
+ "OBJECT_ASSOCIATION_NOT_FOUND",
1049
+ "ASSOCIATION_LABEL_NOT_FOUND",
1050
+ "PRIMARY_COMPANY_NOT_FOUND",
1051
+ "RESOURCE_MISSING_ASSOCIATION",
1052
+ "HUBSPOT_OBJECT_NOT_FOUND"
1053
+ ]);
1054
+ function buildErrorDescription({
1055
+ errorMessage,
1056
+ detailedMessage,
1057
+ fallbackDescription,
1058
+ preferDetailedMessage = false,
1059
+ errorCode
1060
+ }) {
1061
+ const code = (errorCode ?? "").trim().toUpperCase();
1062
+ const useDetail = preferDetailedMessage || code.length > 0 && DETAILED_MESSAGE_ERROR_CODES.has(code);
1063
+ const detail = detailedMessage?.trim() || "";
1064
+ const primary = errorMessage?.trim() || "";
1065
+ const fallback = fallbackDescription?.trim() || "";
1066
+ if (useDetail && detail) {
1067
+ return detail;
1068
+ }
1069
+ if (primary) {
1070
+ return primary;
1071
+ }
1072
+ if (detail) {
1073
+ return detail;
1074
+ }
1075
+ if (fallback) {
1076
+ return fallback;
1077
+ }
1078
+ return "Something went wrong. Please try again.";
1079
+ }
1080
+ function normalizeErrorCode(code) {
1081
+ return (code ?? "").trim().toUpperCase();
1082
+ }
1083
+ function normalizeCategory(category) {
1084
+ return (category ?? "").trim().toUpperCase();
1085
+ }
1086
+ function resolveConfig(errorCode, category) {
1087
+ const code = normalizeErrorCode(errorCode);
1088
+ if (code && API_ERROR_DISPLAY_CONFIG[code]) {
1089
+ return API_ERROR_DISPLAY_CONFIG[code];
1090
+ }
1091
+ const cat = normalizeCategory(category);
1092
+ if (cat && API_ERROR_CATEGORY_FALLBACK[cat]) {
1093
+ return API_ERROR_CATEGORY_FALLBACK[cat];
1094
+ }
1095
+ return DEFAULT_API_ERROR_DISPLAY;
1096
+ }
1097
+ function fromConfig(config, payload, options) {
1098
+ const allowRetry = options?.allowRetry !== false;
1099
+ const severity = config.severity ?? (config.retry ? "recoverable" : "fatal");
1100
+ return {
1101
+ variant: config.variant,
1102
+ title: config.title,
1103
+ description: buildErrorDescription({
1104
+ errorMessage: payload.errorMessage,
1105
+ detailedMessage: payload.detailedMessage,
1106
+ fallbackDescription: config.fallbackDescription,
1107
+ errorCode: payload.errorCode
1108
+ }),
1109
+ errorCode: payload.errorCode,
1110
+ correlationId: payload.correlationId,
1111
+ showRetry: allowRetry && severity === "recoverable" && Boolean(config.retry),
1112
+ showSupport: Boolean(config.support)
1113
+ };
1114
+ }
1115
+ function resolveTransportDisplay(kind, options) {
1116
+ const allowRetry = options?.allowRetry !== false;
1117
+ switch (kind) {
1118
+ case "service_unavailable":
1119
+ return {
1120
+ ...fromConfig(SERVICE_UNAVAILABLE_DISPLAY, {}, options),
1121
+ showRetry: allowRetry
1122
+ };
1123
+ case "timeout":
1124
+ return {
1125
+ ...fromConfig(TIMEOUT_ERROR_DISPLAY, {}, options),
1126
+ showRetry: allowRetry
1127
+ };
1128
+ case "network":
1129
+ return {
1130
+ ...fromConfig(NETWORK_ERROR_DISPLAY, {}, options),
1131
+ showRetry: allowRetry
1132
+ };
1133
+ case "auth":
1134
+ return fromConfig(API_ERROR_DISPLAY_CONFIG.AUTH_TOKEN_EXPIRED ?? DEFAULT_API_ERROR_DISPLAY, {}, options);
1135
+ default:
1136
+ return fromConfig(DEFAULT_API_ERROR_DISPLAY, {}, options);
1137
+ }
1138
+ }
1139
+ function getApiErrorFromUnknown(error) {
1140
+ if (axios.isAxiosError(error)) {
1141
+ return parseApiErrorPayload(error.response?.data);
1142
+ }
1143
+ if (error && typeof error === "object") {
1144
+ const record = error;
1145
+ if (record.response && typeof record.response === "object") {
1146
+ const response = record.response;
1147
+ return parseApiErrorPayload(response.data);
1148
+ }
1149
+ return parseApiErrorPayload(error);
1150
+ }
1151
+ return {};
1152
+ }
1153
+ function resolveApiErrorDisplay(error, options) {
1154
+ if (!axios.isAxiosError(error) || error.response == null) {
1155
+ const kind = classifyHttpError(error);
1156
+ if (kind !== "unknown" && kind !== "client" && kind !== "server") {
1157
+ return resolveTransportDisplay(kind, options);
1158
+ }
1159
+ if (!axios.isAxiosError(error)) {
1160
+ if (error instanceof Error && error.message.trim()) {
1161
+ return {
1162
+ variant: "error",
1163
+ title: DEFAULT_API_ERROR_DISPLAY.title,
1164
+ description: error.message.trim(),
1165
+ showRetry: options?.allowRetry !== false,
1166
+ showSupport: false
1167
+ };
1168
+ }
1169
+ return fromConfig(DEFAULT_API_ERROR_DISPLAY, {}, options);
1170
+ }
1171
+ }
1172
+ const payload = getApiErrorFromUnknown(error);
1173
+ const hasPayload = Boolean(payload.errorCode || payload.errorMessage || payload.category || payload.correlationId);
1174
+ if (!hasPayload && axios.isAxiosError(error)) {
1175
+ const kind = classifyHttpError(error);
1176
+ if (kind === "service_unavailable" || kind === "timeout" || kind === "network") {
1177
+ return resolveTransportDisplay(kind, options);
1178
+ }
1179
+ }
1180
+ const config = resolveConfig(payload.errorCode, payload.category);
1181
+ return fromConfig(config, payload, options);
1182
+ }
1183
+
1184
+ // src/main/core/errors/resolve-content-variant.ts
1185
+ var VARIANT_TO_CONTENT = {
1186
+ error: "error",
1187
+ access: "no-permission",
1188
+ actionDenied: "action-denied",
1189
+ association: "association-not-found",
1190
+ validation: "error",
1191
+ auth: "auth",
1192
+ rateLimit: "rateLimit",
1193
+ commercial: "commercial",
1194
+ file: "file",
1195
+ integration: "integration",
1196
+ network: "network"
1197
+ };
1198
+ function resolveContentVariantFromErrorVariant(variant) {
1199
+ return VARIANT_TO_CONTENT[variant] ?? "error";
1200
+ }
1201
+
1202
+ // src/main/core/errors/resolve-api-content-state.ts
1203
+ function normalizeErrorCode2(code) {
1204
+ return (code ?? "").trim().toUpperCase();
1205
+ }
1206
+ function normalizeCategory2(category) {
1207
+ return (category ?? "").trim().toUpperCase();
1208
+ }
1209
+ function resolveConfig2(errorCode, category) {
1210
+ const code = normalizeErrorCode2(errorCode);
1211
+ if (code && API_ERROR_DISPLAY_CONFIG[code]) {
1212
+ return API_ERROR_DISPLAY_CONFIG[code];
1213
+ }
1214
+ const cat = normalizeCategory2(category);
1215
+ if (cat && API_ERROR_CATEGORY_FALLBACK[cat]) {
1216
+ return API_ERROR_CATEGORY_FALLBACK[cat];
1217
+ }
1218
+ return DEFAULT_API_ERROR_DISPLAY;
1219
+ }
1220
+ function inferSeverity(config) {
1221
+ if (config.severity) {
1222
+ return config.severity;
1223
+ }
1224
+ if (config.variant === "auth") {
1225
+ return "auth";
1226
+ }
1227
+ if (config.variant === "association" || config.variant === "access" || config.variant === "actionDenied") {
1228
+ return "informational";
1229
+ }
1230
+ if (config.retry) {
1231
+ return "recoverable";
1232
+ }
1233
+ return "fatal";
1234
+ }
1235
+ function inferContentVariant(config) {
1236
+ if (config.contentVariant) {
1237
+ return config.contentVariant;
1238
+ }
1239
+ return resolveContentVariantFromErrorVariant(config.variant);
1240
+ }
1241
+ function resolveApiContentState(error, options) {
1242
+ const base = resolveApiErrorDisplay(error, options);
1243
+ const payload = getApiErrorFromUnknown(error);
1244
+ const config = resolveConfig2(payload.errorCode, payload.category);
1245
+ const severity = inferSeverity(config);
1246
+ const contentVariant = inferContentVariant(config);
1247
+ const allowRetry = options?.allowRetry !== false;
1248
+ const description = buildErrorDescription({
1249
+ errorMessage: payload.errorMessage,
1250
+ detailedMessage: payload.detailedMessage,
1251
+ fallbackDescription: config.fallbackDescription,
1252
+ errorCode: payload.errorCode
1253
+ });
1254
+ const showRetry = allowRetry && severity === "recoverable" && Boolean(config.retry);
1255
+ return {
1256
+ ...base,
1257
+ title: config.title,
1258
+ description,
1259
+ contentVariant,
1260
+ severity,
1261
+ isExpected: severity === "informational",
1262
+ showRetry,
1263
+ showSupport: Boolean(config.support)
1264
+ };
1265
+ }
1266
+ function isExpectedApiError(error) {
1267
+ return resolveApiContentState(error, { allowRetry: false }).isExpected;
1268
+ }
1269
+
1270
+ export { API_ERROR_CATEGORY_FALLBACK, API_ERROR_DISPLAY_CONFIG, WOODSPORTAL_API_ACTIVE_ERROR_CODES, authApi, buildErrorDescription, getApiErrorFromUnknown, hasAuthenticatedAccess, hasValidAccess, isExpectedApiError, isFullyAuthenticated, isMfaPendingSession, recoverMfaGateOnBoot, resolveApiContentState, resolveApiErrorDisplay, resolveAuthRouteAction };
1271
+ //# sourceMappingURL=chunk-BXKFJ5NQ.js.map
1272
+ //# sourceMappingURL=chunk-BXKFJ5NQ.js.map