woodsportal-client-sdk 1.1.5-dev.0 → 4.0.0-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.
- package/CHANGELOG.md +109 -0
- package/README.md +171 -77
- package/dist/adapters/angular/index.d.ts +68 -5
- package/dist/adapters/angular/index.js +8 -7
- package/dist/adapters/angular/index.js.map +1 -1
- package/dist/adapters/react/index.d.ts +68 -5
- package/dist/adapters/react/index.js +7 -6
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +68 -5
- package/dist/adapters/vue/index.js +8 -7
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/auth-utils-VT7HSLMA.js +3 -0
- package/dist/{auth-utils-A4WPJMPK.js.map → auth-utils-VT7HSLMA.js.map} +1 -1
- package/dist/authentication-BfYhAeMs.d.ts +463 -0
- package/dist/cache-purge-G5WkHckd.d.ts +236 -0
- package/dist/chunk-3FUHGFAQ.js +167 -0
- package/dist/chunk-3FUHGFAQ.js.map +1 -0
- package/dist/chunk-4CEUGRRD.js +2034 -0
- package/dist/chunk-4CEUGRRD.js.map +1 -0
- package/dist/chunk-4CTHZLKL.js +20 -0
- package/dist/chunk-4CTHZLKL.js.map +1 -0
- package/dist/chunk-5TLHHOP5.js +1424 -0
- package/dist/chunk-5TLHHOP5.js.map +1 -0
- package/dist/chunk-7KE6XWM5.js +95 -0
- package/dist/chunk-7KE6XWM5.js.map +1 -0
- package/dist/{chunk-Y5MRAAGK.js → chunk-AYTO6ND7.js} +3 -3
- package/dist/chunk-AYTO6ND7.js.map +1 -0
- package/dist/chunk-DZKNBN72.js +399 -0
- package/dist/chunk-DZKNBN72.js.map +1 -0
- package/dist/chunk-F7B4FHUQ.js +504 -0
- package/dist/chunk-F7B4FHUQ.js.map +1 -0
- package/dist/entries/auth.d.ts +68 -0
- package/dist/entries/auth.js +13 -0
- package/dist/entries/auth.js.map +1 -0
- package/dist/entries/crm.d.ts +218 -0
- package/dist/entries/crm.js +24 -0
- package/dist/entries/crm.js.map +1 -0
- package/dist/index-CCwMopD8.d.ts +38 -0
- package/dist/index.d.ts +415 -406
- package/dist/index.js +23 -1720
- package/dist/index.js.map +1 -1
- package/dist/use-sync-DpazhM4d.d.ts +60 -0
- package/dist/use-uploader-2F1zc7Cl.d.ts +23 -0
- package/package.json +53 -8
- package/dist/auth-utils-A4WPJMPK.js +0 -4
- package/dist/chunk-J7MDPY5P.js +0 -54
- package/dist/chunk-J7MDPY5P.js.map +0 -1
- package/dist/chunk-NB7AINV4.js +0 -35
- package/dist/chunk-NB7AINV4.js.map +0 -1
- package/dist/chunk-RDCT25UV.js +0 -1066
- package/dist/chunk-RDCT25UV.js.map +0 -1
- package/dist/chunk-Y5MRAAGK.js.map +0 -1
- package/dist/chunk-YLZA5S7A.js +0 -102
- package/dist/chunk-YLZA5S7A.js.map +0 -1
- package/dist/use-sync-LbURBOs_.d.ts +0 -29
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { M as MutationOptions } from './index-CCwMopD8.js';
|
|
2
|
+
|
|
3
|
+
declare function purge(options?: MutationOptions<unknown, unknown>): {
|
|
4
|
+
mutate: (payload?: Record<string, unknown> | undefined) => Promise<unknown>;
|
|
5
|
+
purge: (payload?: Record<string, unknown> | undefined) => Promise<unknown>;
|
|
6
|
+
purgeCache: (payload?: Record<string, unknown> | undefined) => Promise<unknown>;
|
|
7
|
+
isLoading: () => boolean;
|
|
8
|
+
};
|
|
9
|
+
declare function purgeStatus(purgeJobId: string, options?: MutationOptions<unknown, unknown>): {
|
|
10
|
+
mutate: (payload?: string | undefined) => Promise<unknown>;
|
|
11
|
+
getPurgeStatus: (payload?: string | undefined) => Promise<unknown>;
|
|
12
|
+
isLoading: () => boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
declare function imageUpload(options?: MutationOptions<any, any>): {
|
|
16
|
+
mutate: (payload?: any) => Promise<any>;
|
|
17
|
+
uploadImage: (payload?: any) => Promise<any>;
|
|
18
|
+
imageUpload: (payload?: any) => Promise<any>;
|
|
19
|
+
isLoading: () => boolean;
|
|
20
|
+
};
|
|
21
|
+
declare function attachmentUpload(options?: MutationOptions<any, any>): {
|
|
22
|
+
mutate: (payload?: any) => Promise<any>;
|
|
23
|
+
uploadAttachment: (payload?: any) => Promise<any>;
|
|
24
|
+
attachmentUpload: (payload?: any) => Promise<any>;
|
|
25
|
+
isLoading: () => boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare function list$5(options?: MutationOptions<any, any>): {
|
|
29
|
+
mutate: (payload?: any) => Promise<any>;
|
|
30
|
+
list: (payload?: any) => Promise<any>;
|
|
31
|
+
getFiles: (payload?: any) => Promise<any>;
|
|
32
|
+
isLoading: () => boolean;
|
|
33
|
+
};
|
|
34
|
+
declare function details$1(options?: MutationOptions<any, any>): {
|
|
35
|
+
mutate: (payload?: any) => Promise<any>;
|
|
36
|
+
getDetails: (payload?: any) => Promise<any>;
|
|
37
|
+
getFile: (payload?: any) => Promise<any>;
|
|
38
|
+
isLoading: () => boolean;
|
|
39
|
+
};
|
|
40
|
+
declare function addFolder(options?: MutationOptions<any, any>): {
|
|
41
|
+
mutate: (payload?: any) => Promise<any>;
|
|
42
|
+
addFolder: (payload?: any) => Promise<any>;
|
|
43
|
+
isLoading: () => boolean;
|
|
44
|
+
};
|
|
45
|
+
declare function addFile(options?: MutationOptions<any, any>): {
|
|
46
|
+
mutate: (payload?: any) => Promise<any>;
|
|
47
|
+
addFile: (payload?: any) => Promise<any>;
|
|
48
|
+
isLoading: () => boolean;
|
|
49
|
+
};
|
|
50
|
+
declare function download(options?: MutationOptions<any, any>): {
|
|
51
|
+
mutate: (payload?: any) => Promise<any>;
|
|
52
|
+
download: (payload?: any) => Promise<any>;
|
|
53
|
+
downloadFile: (payload?: any) => Promise<any>;
|
|
54
|
+
isLoading: () => boolean;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
declare function list$4(options?: MutationOptions<any, any>): {
|
|
58
|
+
mutate: (payload?: any) => Promise<any>;
|
|
59
|
+
list: (payload?: any) => Promise<any>;
|
|
60
|
+
getEmails: (payload?: any) => Promise<any>;
|
|
61
|
+
isLoading: () => boolean;
|
|
62
|
+
};
|
|
63
|
+
declare function create$2(options?: MutationOptions<any, any>): {
|
|
64
|
+
mutate: (payload?: any) => Promise<any>;
|
|
65
|
+
create: (payload?: any) => Promise<any>;
|
|
66
|
+
createEmail: (payload?: any) => Promise<any>;
|
|
67
|
+
isLoading: () => boolean;
|
|
68
|
+
};
|
|
69
|
+
declare function update$2(options?: MutationOptions<any, any>): {
|
|
70
|
+
mutate: (payload?: any) => Promise<any>;
|
|
71
|
+
update: (payload?: any) => Promise<any>;
|
|
72
|
+
updateEmail: (payload?: any) => Promise<any>;
|
|
73
|
+
isLoading: () => boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
declare function list$3(options?: MutationOptions<any, any>): {
|
|
77
|
+
mutate: (payload?: any) => Promise<any>;
|
|
78
|
+
list: (payload?: any) => Promise<any>;
|
|
79
|
+
getNotes: (payload?: any) => Promise<any>;
|
|
80
|
+
isLoading: () => boolean;
|
|
81
|
+
};
|
|
82
|
+
declare function create$1(options?: MutationOptions<any, any>): {
|
|
83
|
+
mutate: (payload?: any) => Promise<any>;
|
|
84
|
+
create: (payload?: any) => Promise<any>;
|
|
85
|
+
createNote: (payload?: any) => Promise<any>;
|
|
86
|
+
isLoading: () => boolean;
|
|
87
|
+
};
|
|
88
|
+
declare function update$1(options?: MutationOptions<any, any>): {
|
|
89
|
+
mutate: (payload?: any) => Promise<any>;
|
|
90
|
+
update: (payload?: any) => Promise<any>;
|
|
91
|
+
updateNote: (payload?: any) => Promise<any>;
|
|
92
|
+
isLoading: () => boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
declare function list$2(options?: MutationOptions<any, any>): {
|
|
96
|
+
mutate: (payload?: any) => Promise<any>;
|
|
97
|
+
list: (payload?: any) => Promise<any>;
|
|
98
|
+
getObjects: (payload?: any) => Promise<any>;
|
|
99
|
+
isLoading: () => boolean;
|
|
100
|
+
};
|
|
101
|
+
declare function sideBarList(options?: MutationOptions<any, any>): {
|
|
102
|
+
mutate: (payload?: any) => Promise<any>;
|
|
103
|
+
listSidebar: (payload?: any) => Promise<any>;
|
|
104
|
+
getSideBarObjects: (payload?: any) => Promise<any>;
|
|
105
|
+
isLoading: () => boolean;
|
|
106
|
+
};
|
|
107
|
+
declare function form(options?: MutationOptions<any, any>): {
|
|
108
|
+
mutate: (payload?: any) => Promise<any>;
|
|
109
|
+
getForm: (payload?: any) => Promise<any>;
|
|
110
|
+
getObjectsForm: (payload?: any) => Promise<any>;
|
|
111
|
+
isLoading: () => boolean;
|
|
112
|
+
};
|
|
113
|
+
declare function objectFormOptions(options?: MutationOptions<any, any>): {
|
|
114
|
+
mutate: (payload?: any) => Promise<any>;
|
|
115
|
+
getFormOptions: (payload?: any) => Promise<any>;
|
|
116
|
+
objectFormOptions: (payload?: any) => Promise<any>;
|
|
117
|
+
isLoading: () => boolean;
|
|
118
|
+
};
|
|
119
|
+
declare function create(options?: MutationOptions<any, any>): {
|
|
120
|
+
mutate: (payload?: any) => Promise<any>;
|
|
121
|
+
create: (payload?: any) => Promise<any>;
|
|
122
|
+
createObject: (payload?: any) => Promise<any>;
|
|
123
|
+
isLoading: () => boolean;
|
|
124
|
+
};
|
|
125
|
+
declare function createExisting(options?: MutationOptions<any, any>): {
|
|
126
|
+
mutate: (payload?: any) => Promise<any>;
|
|
127
|
+
createExisting: (payload?: any) => Promise<any>;
|
|
128
|
+
createExistingObject: (payload?: any) => Promise<any>;
|
|
129
|
+
isLoading: () => boolean;
|
|
130
|
+
};
|
|
131
|
+
declare function removeExisting(options?: MutationOptions<any, any>): {
|
|
132
|
+
mutate: (payload?: any) => Promise<any>;
|
|
133
|
+
removeExisting: (payload?: any) => Promise<any>;
|
|
134
|
+
removeExistingObject: (payload?: any) => Promise<any>;
|
|
135
|
+
isLoading: () => boolean;
|
|
136
|
+
};
|
|
137
|
+
declare function details(options?: MutationOptions<any, any>): {
|
|
138
|
+
mutate: (payload?: any) => Promise<any>;
|
|
139
|
+
getDetails: (payload?: any) => Promise<any>;
|
|
140
|
+
getObjectsDetails: (payload?: any) => Promise<any>;
|
|
141
|
+
isLoading: () => boolean;
|
|
142
|
+
};
|
|
143
|
+
declare function update(options?: MutationOptions<any, any>): {
|
|
144
|
+
mutate: (payload?: any) => Promise<any>;
|
|
145
|
+
updateDetails: (payload?: any) => Promise<any>;
|
|
146
|
+
updateObjectsDetails: (payload?: any) => Promise<any>;
|
|
147
|
+
isLoading: () => boolean;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
declare function list$1(options?: MutationOptions<any, any>): {
|
|
151
|
+
mutate: (payload?: any) => Promise<any>;
|
|
152
|
+
list: (payload?: any) => Promise<any>;
|
|
153
|
+
getStages: (payload?: any) => Promise<any>;
|
|
154
|
+
isLoading: () => boolean;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
declare function list(options?: MutationOptions<any, any>): {
|
|
158
|
+
mutate: (payload?: any) => Promise<any>;
|
|
159
|
+
list: (payload?: any) => Promise<any>;
|
|
160
|
+
getPipelines: (payload?: any) => Promise<any>;
|
|
161
|
+
isLoading: () => boolean;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type CachePurgeMode = 'soft' | 'hard';
|
|
165
|
+
type CachePurgeDomain = 'crm_object_data' | 'portal_object_config' | 'user_session';
|
|
166
|
+
type CachePurgeView = 'list' | 'single' | 'board' | 'notes' | 'emails' | 'files';
|
|
167
|
+
type CachePurgeListQuery = {
|
|
168
|
+
sort?: string;
|
|
169
|
+
search?: string;
|
|
170
|
+
filterPropertyName?: string;
|
|
171
|
+
filterOperator?: string;
|
|
172
|
+
filterValue?: string;
|
|
173
|
+
page?: number;
|
|
174
|
+
limit?: number;
|
|
175
|
+
view?: 'LIST' | 'BOARD';
|
|
176
|
+
mediatorObjectTypeId?: string;
|
|
177
|
+
mediatorObjectRecordId?: string;
|
|
178
|
+
parentObjectTypeId?: string;
|
|
179
|
+
parentObjectRecordId?: string;
|
|
180
|
+
isPrimaryCompany?: boolean;
|
|
181
|
+
stageId?: string;
|
|
182
|
+
after?: string;
|
|
183
|
+
};
|
|
184
|
+
type CachePurgeTarget = {
|
|
185
|
+
domain: CachePurgeDomain;
|
|
186
|
+
objectTypeId?: string;
|
|
187
|
+
objectTypeIds?: string[];
|
|
188
|
+
recordIds?: string[];
|
|
189
|
+
engagementItemIds?: string[];
|
|
190
|
+
fileIds?: string[];
|
|
191
|
+
views?: CachePurgeView[];
|
|
192
|
+
listQuery?: CachePurgeListQuery;
|
|
193
|
+
};
|
|
194
|
+
type CachePurgeRequest = {
|
|
195
|
+
mode: CachePurgeMode;
|
|
196
|
+
warm?: boolean;
|
|
197
|
+
confirmPortalWide?: boolean;
|
|
198
|
+
includeShortOnHard?: boolean;
|
|
199
|
+
includeContactAccess?: boolean;
|
|
200
|
+
postCrmWrite?: boolean;
|
|
201
|
+
warmListDelayMs?: number;
|
|
202
|
+
targets: CachePurgeTarget[];
|
|
203
|
+
};
|
|
204
|
+
type CachePurgeJobStatus = 'warming' | 'completed' | 'failed';
|
|
205
|
+
type PurgeResult = {
|
|
206
|
+
ok: boolean;
|
|
207
|
+
purgeJobId?: string;
|
|
208
|
+
status?: CachePurgeJobStatus;
|
|
209
|
+
evicted?: Record<string, string[]>;
|
|
210
|
+
warnings?: string[];
|
|
211
|
+
errorCode?: 'PURGE_API_DISABLED' | 'RATE_LIMITED' | 'VALIDATION' | 'WARM_FAILED' | 'NETWORK' | 'UNKNOWN';
|
|
212
|
+
message?: string;
|
|
213
|
+
};
|
|
214
|
+
type CreateCachePurgeJobOptions = {
|
|
215
|
+
idempotencyKey?: string;
|
|
216
|
+
waitForWarm?: boolean;
|
|
217
|
+
pollTimeoutMs?: number;
|
|
218
|
+
pollIntervalMs?: number;
|
|
219
|
+
};
|
|
220
|
+
type CrmCachePurgeOptions = {
|
|
221
|
+
objectTypeId: string;
|
|
222
|
+
objectTypeIds?: string[];
|
|
223
|
+
mode?: CachePurgeMode;
|
|
224
|
+
warm?: boolean;
|
|
225
|
+
listQuery?: CachePurgeListQuery;
|
|
226
|
+
views?: CachePurgeView[];
|
|
227
|
+
recordIds?: string[];
|
|
228
|
+
fileIds?: string[];
|
|
229
|
+
postCrmWrite?: boolean;
|
|
230
|
+
warmListDelayMs?: number;
|
|
231
|
+
engagementItemIds?: string[];
|
|
232
|
+
waitForWarm?: boolean;
|
|
233
|
+
idempotencyKey?: string;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export { type CachePurgeRequest as A, type CachePurgeListQuery as B, type CachePurgeTarget as C, type CachePurgeView as D, type CreateCachePurgeJobOptions as E, type CrmCachePurgeOptions as F, type CachePurgeDomain as G, type CachePurgeMode as H, type PurgeResult as P, list$1 as a, list$2 as b, create as c, details as d, createExisting as e, form as f, list$3 as g, create$1 as h, update$1 as i, list$4 as j, create$2 as k, list as l, update$2 as m, list$5 as n, objectFormOptions as o, details$1 as p, download as q, removeExisting as r, sideBarList as s, addFolder as t, update as u, addFile as v, imageUpload as w, attachmentUpload as x, purge as y, purgeStatus as z };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
2
|
+
|
|
3
|
+
// src/main/core/utils/cookie.ts
|
|
4
|
+
var setCookie = (key, value, expire) => {
|
|
5
|
+
return Cookies.set(key, value, {
|
|
6
|
+
expires: expire,
|
|
7
|
+
sameSite: "none",
|
|
8
|
+
secure: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var getCookie = (key) => {
|
|
12
|
+
return Cookies.get(key);
|
|
13
|
+
};
|
|
14
|
+
var removeAllCookie = () => {
|
|
15
|
+
Object.keys(Cookies.get()).forEach((cookieName) => {
|
|
16
|
+
Cookies.remove(cookieName);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var isCookieExpired = (key) => {
|
|
20
|
+
const value = Cookies.get(key);
|
|
21
|
+
if (value === void 0) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(value);
|
|
26
|
+
if (parsed && typeof parsed === "object" && "expiresAt" in parsed) {
|
|
27
|
+
const expiresAt = parsed.expiresAt;
|
|
28
|
+
return typeof expiresAt === "number" && Date.now() > expiresAt;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
} catch {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/main/core/utils/constants.ts
|
|
37
|
+
var LOGIN_DETAILS = "loginDetails";
|
|
38
|
+
var REFRESH_TOKEN = "refreshToken";
|
|
39
|
+
var PORTAL = "portal";
|
|
40
|
+
var SUBSCRIPTION_TYPE = "subscriptionType";
|
|
41
|
+
var HUBSPOT_DATA = "hubSpotData";
|
|
42
|
+
var HUB_ID = "hubId";
|
|
43
|
+
var DEV_PORTAL_ID = "devPortalId";
|
|
44
|
+
var PORTAL_ID = "portalId";
|
|
45
|
+
var DEV_API_URL = "devApiUrl";
|
|
46
|
+
|
|
47
|
+
// src/main/core/utils/storage-keys.ts
|
|
48
|
+
var defaults = {
|
|
49
|
+
loginDetails: LOGIN_DETAILS,
|
|
50
|
+
refreshToken: REFRESH_TOKEN,
|
|
51
|
+
portal: PORTAL,
|
|
52
|
+
subscriptionType: SUBSCRIPTION_TYPE,
|
|
53
|
+
authUser: LOGIN_DETAILS
|
|
54
|
+
};
|
|
55
|
+
var runtimeKeys = { ...defaults };
|
|
56
|
+
function configureStorageKeys(overrides = {}) {
|
|
57
|
+
runtimeKeys = { ...defaults, ...runtimeKeys, ...overrides };
|
|
58
|
+
}
|
|
59
|
+
function getStorageKeys() {
|
|
60
|
+
return runtimeKeys;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/main/core/http/token-store.ts
|
|
64
|
+
var accessToken = null;
|
|
65
|
+
var tokenExpiresAt = null;
|
|
66
|
+
var refreshCallback = null;
|
|
67
|
+
function getAccessToken() {
|
|
68
|
+
return accessToken;
|
|
69
|
+
}
|
|
70
|
+
function storAccessToken(token, expiresIn) {
|
|
71
|
+
accessToken = token;
|
|
72
|
+
if (expiresIn) {
|
|
73
|
+
tokenExpiresAt = Date.now() + expiresIn * 1e3;
|
|
74
|
+
} else {
|
|
75
|
+
tokenExpiresAt = null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function clearAccessToken() {
|
|
79
|
+
accessToken = null;
|
|
80
|
+
tokenExpiresAt = null;
|
|
81
|
+
}
|
|
82
|
+
function isExpiresAccessToken() {
|
|
83
|
+
if (!tokenExpiresAt) return true;
|
|
84
|
+
return Date.now() >= tokenExpiresAt;
|
|
85
|
+
}
|
|
86
|
+
function setRefreshCallback(callback) {
|
|
87
|
+
refreshCallback = callback;
|
|
88
|
+
}
|
|
89
|
+
async function ensureValidRefresh() {
|
|
90
|
+
if (isExpiresAccessToken() && refreshCallback) {
|
|
91
|
+
const { getRefreshToken: getRefreshToken2 } = await import('./auth-utils-VT7HSLMA.js');
|
|
92
|
+
const refreshToken = getRefreshToken2();
|
|
93
|
+
if (refreshToken) {
|
|
94
|
+
await refreshCallback(refreshToken);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function isAuthenticateApp() {
|
|
99
|
+
if (isCookieExpired(getStorageKeys().refreshToken) || isExpiresAccessToken()) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
function isAuthenticated() {
|
|
105
|
+
return isAuthenticateApp();
|
|
106
|
+
}
|
|
107
|
+
function isAccessTokenExpired() {
|
|
108
|
+
return isExpiresAccessToken();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/main/core/http/auth-utils.ts
|
|
112
|
+
var setLoggedInDetails = async (data) => {
|
|
113
|
+
return new Promise((resolve) => {
|
|
114
|
+
const keys = getStorageKeys();
|
|
115
|
+
setCookie(keys.loginDetails, JSON.stringify(data));
|
|
116
|
+
if (keys.authUser !== keys.loginDetails) {
|
|
117
|
+
setCookie(keys.authUser, JSON.stringify(data));
|
|
118
|
+
}
|
|
119
|
+
resolve();
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var setProfileDetails = async (data) => {
|
|
123
|
+
return new Promise((resolve) => {
|
|
124
|
+
setCookie(getStorageKeys().loginDetails, JSON.stringify(data));
|
|
125
|
+
resolve();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
function setRefreshToken(token, expiresAt) {
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
setCookie(getStorageKeys().refreshToken, JSON.stringify(token), expiresAt);
|
|
131
|
+
resolve();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function setAccessToken(token, expiresIn) {
|
|
135
|
+
return new Promise((resolve) => {
|
|
136
|
+
storAccessToken(token, expiresIn);
|
|
137
|
+
resolve();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
var setPortal = async (data) => {
|
|
141
|
+
return new Promise((resolve) => {
|
|
142
|
+
setCookie(getStorageKeys().portal, JSON.stringify(data));
|
|
143
|
+
resolve();
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
var setSubscriptionType = async (data) => {
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
setCookie(getStorageKeys().subscriptionType, JSON.stringify(data));
|
|
149
|
+
resolve();
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
function getProfile() {
|
|
153
|
+
return JSON.parse(getCookie(getStorageKeys().loginDetails || null) || null);
|
|
154
|
+
}
|
|
155
|
+
function getRefreshToken() {
|
|
156
|
+
return JSON.parse(getCookie(getStorageKeys().refreshToken || null) || null);
|
|
157
|
+
}
|
|
158
|
+
function getPortal() {
|
|
159
|
+
return JSON.parse(getCookie(getStorageKeys().portal || null) || null);
|
|
160
|
+
}
|
|
161
|
+
function getSubscriptionType() {
|
|
162
|
+
return JSON.parse(getCookie(getStorageKeys().subscriptionType || null) || null);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export { DEV_API_URL, DEV_PORTAL_ID, HUBSPOT_DATA, HUB_ID, PORTAL_ID, clearAccessToken, configureStorageKeys, ensureValidRefresh, getAccessToken, getCookie, getPortal, getProfile, getRefreshToken, getSubscriptionType, isAccessTokenExpired, isAuthenticateApp, isAuthenticated, isCookieExpired, isExpiresAccessToken, removeAllCookie, setAccessToken, setLoggedInDetails, setPortal, setProfileDetails, setRefreshCallback, setRefreshToken, setSubscriptionType };
|
|
166
|
+
//# sourceMappingURL=chunk-3FUHGFAQ.js.map
|
|
167
|
+
//# sourceMappingURL=chunk-3FUHGFAQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main/core/utils/cookie.ts","../src/main/core/utils/constants.ts","../src/main/core/utils/storage-keys.ts","../src/main/core/http/token-store.ts","../src/main/core/http/auth-utils.ts"],"names":["getRefreshToken"],"mappings":";;;AAEO,IAAM,SAAA,GAAY,CAAC,GAAA,EAAa,KAAA,EAAe,MAAA,KAA2B;AAC7E,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,KAAA,EAAO;AAAA,IAC3B,OAAA,EAAS,MAAA;AAAA,IACT,QAAA,EAAU,MAAA;AAAA,IACV,MAAA,EAAQ;AAAA,GACX,CAAA;AACL,CAAA;AAEO,IAAM,SAAA,GAAiB,CAAC,GAAA,KAAa;AACxC,EAAA,OAAO,OAAA,CAAQ,IAAI,GAAG,CAAA;AAC1B;AAMO,IAAM,kBAAkB,MAAM;AACjC,EAAA,MAAA,CAAO,KAAK,OAAA,CAAQ,GAAA,EAAK,CAAA,CAAE,OAAA,CAAQ,CAAC,UAAA,KAAe;AAC/C,IAAA,OAAA,CAAQ,OAAO,UAAU,CAAA;AAAA,EAC7B,CAAC,CAAA;AACL;AAOO,IAAM,eAAA,GAAkB,CAAC,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AO,IAAA,KAAc;AAC1C,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAiB;AACjC,IAAA,SAAA,CAAU,gBAAe,CAAE,MAAA,EAAQ,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AACvD,IAAA,OAAA,EAAQ;AAAA,EACZ,CAAC,CAAA;AACL;AAEO,IAAM,mBAAA,GAAsB,OAAO,IAAA,KAAc;AACpD,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAiB;AACjC,IAAA,SAAA,CAAU,gBAAe,CAAE,gBAAA,EAAkB,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AACjE,IAAA,OAAA,EAAQ;AAAA,EACZ,CAAC,CAAA;AACL;AAGO,SAAS,UAAA,GAA4B;AACxC,EAAA,OAAO,IAAA,CAAK,MAAM,SAAA,CAAU,cAAA,GAAiB,YAAA,IAAgB,IAAI,KAAK,IAAI,CAAA;AAC9E;AAEO,SAAS,eAAA,GAAiC;AAC7C,EAAA,OAAO,IAAA,CAAK,MAAM,SAAA,CAAU,cAAA,GAAiB,YAAA,IAAgB,IAAI,KAAK,IAAI,CAAA;AAC9E;AAEO,SAAS,SAAA,GAAwB;AACpC,EAAA,OAAO,IAAA,CAAK,MAAM,SAAA,CAAU,cAAA,GAAiB,MAAA,IAAU,IAAI,KAAK,IAAI,CAAA;AACxE;AAEO,SAAS,mBAAA,GAAqC;AACjD,EAAA,OAAO,IAAA,CAAK,MAAM,SAAA,CAAU,cAAA,GAAiB,gBAAA,IAAoB,IAAI,KAAK,IAAI,CAAA;AAClF","file":"chunk-3FUHGFAQ.js","sourcesContent":["import Cookies from 'js-cookie'\n\nexport const setCookie = (key: string, value: string, expire?: number | Date) => {\n return Cookies.set(key, value, {\n expires: expire,\n sameSite: 'none',\n secure: true\n })\n}\n\nexport const getCookie: any = (key: any) => {\n return Cookies.get(key)\n}\n\nexport const removeCookie = (key: any) => {\n return Cookies.remove(key)\n}\n\nexport const removeAllCookie = () => {\n Object.keys(Cookies.get()).forEach((cookieName) => {\n Cookies.remove(cookieName)\n })\n}\n\n// export const isCookieExpired = (key: string): boolean => {\n// const value = Cookies.get(key);\n// return value === undefined; // true means expired or never set\n// };\n\nexport const isCookieExpired = (key: string): boolean => {\n const value = Cookies.get(key)\n if (value === undefined) {\n return true\n }\n try {\n const parsed = JSON.parse(value)\n if (parsed && typeof parsed === 'object' && 'expiresAt' in parsed) {\n const expiresAt = (parsed as { expiresAt?: number }).expiresAt\n return typeof expiresAt === 'number' && Date.now() > expiresAt\n }\n // Refresh/auth cookies store a JSON-encoded string token; rely on browser cookie expiry.\n return false\n } catch {\n return true\n }\n}\n","// cookies\nexport const LOGIN_DETAILS = 'loginDetails'\nexport const REFRESH_TOKEN = 'refreshToken'\nexport const PORTAL = 'portal'\nexport const SUBSCRIPTION_TYPE = 'subscriptionType'\n\n// variables\nexport const HUBSPOT_DATA = 'hubSpotData'\nexport const HUB_ID = 'hubId'\nexport const DEV_PORTAL_ID = 'devPortalId'\nexport const PORTAL_ID = 'portalId'\nexport const DEV_API_URL = 'devApiUrl'\n","import { LOGIN_DETAILS, PORTAL, REFRESH_TOKEN, SUBSCRIPTION_TYPE } from './constants'\n\nexport interface StorageKeyConfig {\n loginDetails?: string\n refreshToken?: string\n portal?: string\n subscriptionType?: string\n authUser?: string\n}\n\nconst defaults: Required<StorageKeyConfig> = {\n loginDetails: LOGIN_DETAILS,\n refreshToken: REFRESH_TOKEN,\n portal: PORTAL,\n subscriptionType: SUBSCRIPTION_TYPE,\n authUser: LOGIN_DETAILS\n}\n\nlet runtimeKeys: Required<StorageKeyConfig> = { ...defaults }\n\nexport function configureStorageKeys(overrides: StorageKeyConfig = {}): void {\n runtimeKeys = { ...defaults, ...runtimeKeys, ...overrides }\n}\n\n/** Test helper — restore default cookie key names. */\nexport function resetStorageKeysForTests(): void {\n runtimeKeys = { ...defaults }\n}\n\nexport function getStorageKeys(): Readonly<Required<StorageKeyConfig>> {\n return runtimeKeys\n}\n","/**\n * Token storage utilities\n * These functions handle access token management\n */\n\nimport { isCookieExpired } from '../utils/cookie.js'\nimport { getStorageKeys } from '../utils/storage-keys'\n\nlet accessToken: string | null = null\nlet tokenExpiresAt: number | null = null\nlet refreshCallback: ((refreshToken: string) => Promise<{ token: string | null; success: boolean }>) | null = null\n\nexport function getAccessToken(): string | null {\n return accessToken\n}\n\nexport function storAccessToken(token: string, expiresIn?: number): void {\n accessToken = token\n if (expiresIn) {\n tokenExpiresAt = Date.now() + expiresIn * 1000\n } else {\n tokenExpiresAt = null\n }\n}\n\nexport function clearAccessToken(): void {\n accessToken = null\n tokenExpiresAt = null\n}\n\nexport function isExpiresAccessToken(): boolean {\n if (!tokenExpiresAt) return true\n return Date.now() >= tokenExpiresAt\n}\n\n/**\n * Set the refresh callback function\n * This is called by the HTTP client during initialization\n */\nexport function setRefreshCallback(callback: (refreshToken: string) => Promise<{ token: string | null; success: boolean }>): void {\n refreshCallback = callback\n}\n\n/**\n * Ensures the access token is valid, refreshing if necessary\n */\nexport async function ensureValidRefresh(): Promise<void> {\n if (isExpiresAccessToken() && refreshCallback) {\n const { getRefreshToken } = await import('./auth-utils.js')\n const refreshToken = getRefreshToken()\n if (refreshToken) {\n await refreshCallback(refreshToken)\n }\n }\n}\n\nexport function isAuthenticateApp() {\n if (isCookieExpired(getStorageKeys().refreshToken) || isExpiresAccessToken()) {\n return false\n }\n return true\n}\n\n/** Preferred 3.0 name for {@link isAuthenticateApp}. */\nexport function isAuthenticated() {\n return isAuthenticateApp()\n}\n\n/** Preferred 3.0 name for {@link isExpiresAccessToken}. */\nexport function isAccessTokenExpired() {\n return isExpiresAccessToken()\n}\n","/**\n * Authentication utility functions\n * These handle refresh token management\n */\n\nimport { setCookie, getCookie } from '../utils/cookie'\nimport { getStorageKeys } from '../utils/storage-keys'\nimport { storAccessToken } from './token-store'\n\n// Set data\nexport const setLoggedInDetails = async (data: any) => {\n return new Promise((resolve: any) => {\n const keys = getStorageKeys()\n setCookie(keys.loginDetails, JSON.stringify(data))\n if (keys.authUser !== keys.loginDetails) {\n setCookie(keys.authUser, JSON.stringify(data))\n }\n resolve()\n })\n}\n\nexport const setProfileDetails = async (data: any) => {\n return new Promise((resolve: any) => {\n setCookie(getStorageKeys().loginDetails, JSON.stringify(data))\n resolve()\n })\n}\n\nexport function setRefreshToken(token: string, expiresAt: number) {\n return new Promise((resolve: any) => {\n setCookie(getStorageKeys().refreshToken, JSON.stringify(token), expiresAt)\n resolve()\n })\n}\n\nexport function setAccessToken(token: string, expiresIn?: number) {\n return new Promise((resolve: any) => {\n storAccessToken(token, expiresIn)\n resolve()\n })\n}\n\nexport const setPortal = async (data: any) => {\n return new Promise((resolve: any) => {\n setCookie(getStorageKeys().portal, JSON.stringify(data))\n resolve()\n })\n}\n\nexport const setSubscriptionType = async (data: any) => {\n return new Promise((resolve: any) => {\n setCookie(getStorageKeys().subscriptionType, JSON.stringify(data))\n resolve()\n })\n}\n\n// Get data\nexport function getProfile(): string | null {\n return JSON.parse(getCookie(getStorageKeys().loginDetails || null) || null)\n}\n\nexport function getRefreshToken(): string | null {\n return JSON.parse(getCookie(getStorageKeys().refreshToken || null) || null)\n}\n\nexport function getPortal(): any | null {\n return JSON.parse(getCookie(getStorageKeys().portal || null) || null)\n}\n\nexport function getSubscriptionType(): string | null {\n return JSON.parse(getCookie(getStorageKeys().subscriptionType || null) || null)\n}\n"]}
|