@plutonhq/core-frontend 0.1.14 → 0.1.17
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-lib/components/App/Footer/Footer.d.ts +2 -1
- package/dist-lib/components/App/Footer/Footer.d.ts.map +1 -1
- package/dist-lib/components/App/Footer/Footer.js +29 -18
- package/dist-lib/components/App/Footer/Footer.js.map +1 -1
- package/dist-lib/components/Plan/PlanForm/PlanForm.js +74 -74
- package/dist-lib/components/Plan/PlanForm/PlanForm.js.map +1 -1
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.d.ts +16 -0
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.d.ts.map +1 -0
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.js +115 -0
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.js.map +1 -0
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.module.scss.js +26 -0
- package/dist-lib/components/Plan/PlanIntegrity/PlanIntegrity.module.scss.js.map +1 -0
- package/dist-lib/components/Plan/PlanPendingBackup/PlanPendingBackup.d.ts +2 -2
- package/dist-lib/components/Plan/PlanPendingBackup/PlanPendingBackup.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanPendingBackup/PlanPendingBackup.js.map +1 -1
- package/dist-lib/components/Settings/GeneralSettings/GeneralSettings.d.ts +1 -1
- package/dist-lib/components/Settings/GeneralSettings/GeneralSettings.d.ts.map +1 -1
- package/dist-lib/components/Settings/GeneralSettings/GeneralSettings.js +55 -27
- package/dist-lib/components/Settings/GeneralSettings/GeneralSettings.js.map +1 -1
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.d.ts +7 -0
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.d.ts.map +1 -0
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.js +79 -0
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.js.map +1 -0
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.module.scss.js +24 -0
- package/dist-lib/components/Settings/TwoFactorSetup/TwoFactorSetup.module.scss.js.map +1 -0
- package/dist-lib/components/index.d.ts +2 -0
- package/dist-lib/components/index.d.ts.map +1 -1
- package/dist-lib/components.js +73 -69
- package/dist-lib/components.js.map +1 -1
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js +68 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +7 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/utils.js +55 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-core@5.96.0/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-persist-client-core@5.96.0/node_modules/@tanstack/query-persist-client-core/build/modern/createPersister.js +190 -0
- package/dist-lib/node_modules/.pnpm/@tanstack_query-persist-client-core@5.96.0/node_modules/@tanstack/query-persist-client-core/build/modern/createPersister.js.map +1 -0
- package/dist-lib/router.d.ts.map +1 -1
- package/dist-lib/router.js +42 -39
- package/dist-lib/router.js.map +1 -1
- package/dist-lib/routes/PlanSingle/PlanSingle.d.ts.map +1 -1
- package/dist-lib/routes/PlanSingle/PlanSingle.js +123 -98
- package/dist-lib/routes/PlanSingle/PlanSingle.js.map +1 -1
- package/dist-lib/services/plans.d.ts +6 -0
- package/dist-lib/services/plans.d.ts.map +1 -1
- package/dist-lib/services/plans.js +151 -127
- package/dist-lib/services/plans.js.map +1 -1
- package/dist-lib/services/settings.d.ts +18 -0
- package/dist-lib/services/settings.d.ts.map +1 -1
- package/dist-lib/services/settings.js +182 -72
- package/dist-lib/services/settings.js.map +1 -1
- package/dist-lib/services/users.d.ts +1 -1
- package/dist-lib/services/users.d.ts.map +1 -1
- package/dist-lib/services/users.js.map +1 -1
- package/dist-lib/services.js +98 -88
- package/dist-lib/styles/core-frontend.css +1 -1
- package/dist-lib/utils/helpers.d.ts +1 -0
- package/dist-lib/utils/helpers.d.ts.map +1 -1
- package/dist-lib/utils/helpers.js +74 -70
- package/dist-lib/utils/helpers.js.map +1 -1
- package/dist-lib/utils.js +28 -27
- package/package.json +5 -4
- package/src/components/App/Footer/Footer.tsx +17 -2
- package/src/components/Plan/PlanForm/PlanForm.tsx +14 -14
- package/src/components/Plan/PlanIntegrity/PlanIntegrity.module.scss +110 -0
- package/src/components/Plan/PlanIntegrity/PlanIntegrity.tsx +187 -0
- package/src/components/Plan/PlanPendingBackup/PlanPendingBackup.tsx +2 -2
- package/src/components/Settings/GeneralSettings/GeneralSettings.tsx +37 -1
- package/src/components/Settings/TwoFactorSetup/TwoFactorSetup.module.scss +62 -0
- package/src/components/Settings/TwoFactorSetup/TwoFactorSetup.tsx +102 -0
- package/src/components/index.ts +2 -0
- package/src/router.tsx +6 -1
- package/src/routes/PlanSingle/PlanSingle.tsx +21 -0
- package/src/services/plans.ts +30 -0
- package/src/services/settings.ts +126 -0
- package/src/services/users.ts +1 -1
- package/src/utils/helpers.ts +26 -0
package/src/services/settings.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { experimental_createQueryPersister } from '@tanstack/react-query-persist-client';
|
|
2
3
|
import { API_URL } from '../utils/constants';
|
|
4
|
+
import { useNavigate } from 'react-router';
|
|
3
5
|
|
|
4
6
|
// ============== Settings API ==============
|
|
5
7
|
|
|
@@ -211,3 +213,127 @@ export function useCompleteSetup() {
|
|
|
211
213
|
mutationFn: completeSetup,
|
|
212
214
|
});
|
|
213
215
|
}
|
|
216
|
+
|
|
217
|
+
// Two-Factor Authentication (2FA) Setup and Verification
|
|
218
|
+
|
|
219
|
+
export async function setupTwoFactorAuth(id: number) {
|
|
220
|
+
const headers = new Headers({ 'Content-Type': 'application/json', Accept: 'application/json' });
|
|
221
|
+
const res = await fetch(`${API_URL}/settings/${id}/2fa/setup`, {
|
|
222
|
+
method: 'POST',
|
|
223
|
+
headers,
|
|
224
|
+
credentials: 'include',
|
|
225
|
+
});
|
|
226
|
+
// Check if response is ok
|
|
227
|
+
if (!res.ok) {
|
|
228
|
+
const data = await res.json();
|
|
229
|
+
throw new Error(data.error);
|
|
230
|
+
}
|
|
231
|
+
const data = await res.json();
|
|
232
|
+
return data;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function useSetupTwoFactorAuth() {
|
|
236
|
+
return useMutation({
|
|
237
|
+
mutationFn: setupTwoFactorAuth,
|
|
238
|
+
onSuccess: (res) => {
|
|
239
|
+
console.log('# 2FA setup data fetched successfully! :', res);
|
|
240
|
+
},
|
|
241
|
+
onError: (res) => {
|
|
242
|
+
console.log('# 2FA setup data fetch failed! :', res);
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
export async function verifyTwoFactorAuth({ code, id }: { code: string; id: number }) {
|
|
247
|
+
const headers = new Headers({ 'Content-Type': 'application/json', Accept: 'application/json' });
|
|
248
|
+
const res = await fetch(`${API_URL}/settings/${id}/2fa/finalize`, {
|
|
249
|
+
method: 'POST',
|
|
250
|
+
headers,
|
|
251
|
+
credentials: 'include',
|
|
252
|
+
body: JSON.stringify({ code }),
|
|
253
|
+
});
|
|
254
|
+
// Check if response is ok
|
|
255
|
+
if (!res.ok) {
|
|
256
|
+
const data = await res.json();
|
|
257
|
+
throw new Error(data.error);
|
|
258
|
+
}
|
|
259
|
+
const data = await res.json();
|
|
260
|
+
return data;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function useVerifyTwoFactorAuth() {
|
|
264
|
+
return useMutation({
|
|
265
|
+
mutationFn: verifyTwoFactorAuth,
|
|
266
|
+
onSuccess: (res) => {
|
|
267
|
+
console.log('# 2FA verification successful! :', res);
|
|
268
|
+
},
|
|
269
|
+
onError: (res) => {
|
|
270
|
+
console.log('# 2FA verification failed! :', res);
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export async function verifyTwoFactorOTP({ code }: { code: string }) {
|
|
276
|
+
const headers = new Headers({ 'Content-Type': 'application/json', Accept: 'application/json' });
|
|
277
|
+
const res = await fetch(`${API_URL}/user/verify-otp`, {
|
|
278
|
+
method: 'POST',
|
|
279
|
+
headers,
|
|
280
|
+
credentials: 'include',
|
|
281
|
+
body: JSON.stringify({ code }),
|
|
282
|
+
});
|
|
283
|
+
// Check if response is ok
|
|
284
|
+
if (!res.ok) {
|
|
285
|
+
const data = await res.json();
|
|
286
|
+
throw new Error(data.error);
|
|
287
|
+
}
|
|
288
|
+
const data = await res.json();
|
|
289
|
+
return data;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function useVerifyTwoFactorOTP() {
|
|
293
|
+
const navigate = useNavigate();
|
|
294
|
+
return useMutation({
|
|
295
|
+
mutationFn: verifyTwoFactorOTP,
|
|
296
|
+
onSuccess: (res) => {
|
|
297
|
+
console.log('# 2FA verification successful! :', res);
|
|
298
|
+
navigate('/');
|
|
299
|
+
},
|
|
300
|
+
onError: (res) => {
|
|
301
|
+
console.log('# 2FA verification failed! :', res);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// check latest version
|
|
307
|
+
export async function checkLatestVersion() {
|
|
308
|
+
const res = await fetch(`${API_URL}/settings/version/latest`, {
|
|
309
|
+
method: 'GET',
|
|
310
|
+
credentials: 'include',
|
|
311
|
+
});
|
|
312
|
+
if (!res.ok) {
|
|
313
|
+
const data = await res.json();
|
|
314
|
+
throw new Error(data.error);
|
|
315
|
+
}
|
|
316
|
+
const data = await res.json();
|
|
317
|
+
return data;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const SIX_HOURS = 1000 * 60 * 60 * 6;
|
|
321
|
+
|
|
322
|
+
const { persisterFn: latestVersionPersister } = experimental_createQueryPersister({
|
|
323
|
+
storage: window.localStorage,
|
|
324
|
+
maxAge: SIX_HOURS,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export function useCheckLatestVersion() {
|
|
328
|
+
return useQuery({
|
|
329
|
+
queryKey: ['latestVersion'],
|
|
330
|
+
queryFn: () => checkLatestVersion(),
|
|
331
|
+
persister: latestVersionPersister,
|
|
332
|
+
retry: false,
|
|
333
|
+
staleTime: SIX_HOURS,
|
|
334
|
+
gcTime: SIX_HOURS,
|
|
335
|
+
refetchOnWindowFocus: false,
|
|
336
|
+
refetchOnReconnect: false,
|
|
337
|
+
refetchOnMount: false,
|
|
338
|
+
});
|
|
339
|
+
}
|
package/src/services/users.ts
CHANGED
package/src/utils/helpers.ts
CHANGED
|
@@ -191,6 +191,8 @@ export const getProcessorIcon = (brand: string) => {
|
|
|
191
191
|
return 'processor';
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
+
// Compares two version strings (e.g., "1.2.3" and "1.3.0")
|
|
195
|
+
// returns true if the latest version is newer than the current version
|
|
194
196
|
export const compareVersions = (current: string, latest: string) => {
|
|
195
197
|
if (!current || !latest) return false;
|
|
196
198
|
const currentParts = current.split('.').map(Number);
|
|
@@ -206,6 +208,30 @@ export const compareVersions = (current: string, latest: string) => {
|
|
|
206
208
|
return false;
|
|
207
209
|
};
|
|
208
210
|
|
|
211
|
+
export const getUpdateDocLink = (isPRO?: boolean) => {
|
|
212
|
+
const installType = (window as any).plutonInstallType || 'unknown';
|
|
213
|
+
console.log('installType :', installType);
|
|
214
|
+
if (installType === 'binary') {
|
|
215
|
+
if (isPRO) {
|
|
216
|
+
return 'https://docs.usepluton.com/docs/pluton-pro/install-pluton-pro-desktop#updating';
|
|
217
|
+
}
|
|
218
|
+
return 'https://docs.usepluton.com/docs/getting-started/install-pluton-desktop#updating';
|
|
219
|
+
}
|
|
220
|
+
if (installType === 'server') {
|
|
221
|
+
if (isPRO) {
|
|
222
|
+
return 'https://docs.usepluton.com/docs/pluton-pro/install-pluton-pro-linux-server#updating';
|
|
223
|
+
}
|
|
224
|
+
return 'https://docs.usepluton.com/docs/getting-started/install-pluton-linux-server#updating-pluton';
|
|
225
|
+
}
|
|
226
|
+
if (installType === 'docker') {
|
|
227
|
+
if (isPRO) {
|
|
228
|
+
return 'https://docs.usepluton.com/docs/pluton-pro/deploy-pluton-pro-docker#updating';
|
|
229
|
+
}
|
|
230
|
+
return 'https://docs.usepluton.com/docs/getting-started/deploy-docker#quick-reference';
|
|
231
|
+
}
|
|
232
|
+
return 'https://github.com/plutonhq/pluton/releases/latest';
|
|
233
|
+
};
|
|
234
|
+
|
|
209
235
|
export const isServerEdition = (distro: string, platform: string): boolean => {
|
|
210
236
|
// Check Windows Server editions
|
|
211
237
|
if (platform === 'win32') {
|