@vc-shell/core
Advanced tools
Comparing version 1.0.36 to 1.0.37
@@ -9,2 +9,3 @@ export { default as useFunctions } from "./useFunctions"; | ||
export { default as useAutosave } from "./useAutosave"; | ||
export { default as useAppSwitcher } from "./useAppSwitcher"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { IUseUserFactoryParams, IUseNotificationsFactoryParams, IUseSettingsFactoryParams } from "./factories"; | ||
export interface AuthData { | ||
@@ -19,3 +18,2 @@ accessToken?: string; | ||
} | ||
export type { IUseUserFactoryParams, IUseNotificationsFactoryParams, IUseSettingsFactoryParams, }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@vc-shell/core", | ||
"version": "1.0.36", | ||
"version": "1.0.37", | ||
"scripts": { | ||
@@ -14,7 +14,7 @@ "build": "vite build" | ||
"devDependencies": { | ||
"@vc-shell/config-generator": "^1.0.36", | ||
"@vc-shell/config-generator": "^1.0.37", | ||
"typescript": "^4.6.2" | ||
}, | ||
"dependencies": { | ||
"@vc-shell/api-client": "^1.0.36", | ||
"@vc-shell/api-client": "^1.0.37", | ||
"client-oauth2": "^4.3.3", | ||
@@ -28,3 +28,3 @@ "vue-i18n": "^9.1.7", | ||
}, | ||
"gitHead": "b19cacd1c7265ea9cc71982974224c7f1a66c5a5" | ||
"gitHead": "b0af564c3729c3fba504838ee5728b07858448b5" | ||
} |
@@ -9,1 +9,2 @@ export { default as useFunctions } from "./useFunctions"; | ||
export { default as useAutosave } from "./useAutosave"; | ||
export { default as useAppSwitcher } from "./useAppSwitcher"; |
import { | ||
PushNotification, | ||
PushNotificationClient, | ||
} from "@vc-shell/api-client"; | ||
import useUser from "../useUser"; | ||
import { computed, ComputedRef, inject, readonly, ref } from "vue"; | ||
import { computed, ComputedRef, readonly, ref } from "vue"; | ||
import useLogger from "../useLogger"; | ||
import _ from "lodash-es"; | ||
import { IUseNotificationsFactoryParams } from "../../types"; | ||
const notificationsClient = new PushNotificationClient(); | ||
interface INotifications { | ||
@@ -25,5 +27,2 @@ readonly notifications: ComputedRef<Readonly<PushNotification[]>>; | ||
export default (): INotifications => { | ||
const useNotificationsFactory = inject<IUseNotificationsFactoryParams>( | ||
"useNotificationsFactory" | ||
); | ||
const { getAccessToken } = useUser(); | ||
@@ -37,6 +36,17 @@ const logger = useLogger(); | ||
try { | ||
useNotificationsFactory.setAuthToken(token); | ||
notificationsClient.setAuthToken(token); | ||
const result = await fetch("/api/platform/pushnotifications", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json-patch+json", | ||
Accept: "application/json", | ||
authorization: `Bearer ${token}`, | ||
}, | ||
body: JSON.stringify({ take }), | ||
}); | ||
notifications.value = | ||
await useNotificationsFactory.getPushNotifications(token, take); | ||
result.text().then((response) => { | ||
notifications.value = | ||
<PushNotification[]>JSON.parse(response).notifyEvents ?? []; | ||
}); | ||
} catch (e) { | ||
@@ -83,5 +93,5 @@ logger.error(e); | ||
if (token) { | ||
useNotificationsFactory.setAuthToken(token); | ||
notificationsClient.setAuthToken(token); | ||
try { | ||
await useNotificationsFactory.markAllAsRead(); | ||
await notificationsClient.markAllAsRead(); | ||
notifications.value = notifications.value.map((x) => { | ||
@@ -88,0 +98,0 @@ if (x.isNew) { |
@@ -12,4 +12,6 @@ import useUser from "../useUser"; | ||
function checkPermission(permissions: string | string[]) { | ||
if (permissions || (permissions && permissions instanceof Array)) { | ||
function checkPermission(permissions: string | string[] | undefined) { | ||
if (!permissions) { | ||
return true; | ||
} else if (permissions || (permissions && permissions instanceof Array)) { | ||
if (typeof permissions === "string") { | ||
@@ -16,0 +18,0 @@ return user.value?.permissions.includes(permissions); |
import useUser from "../useUser"; | ||
import useLogger from "../useLogger"; | ||
import { computed, inject, Ref, ref } from "vue"; | ||
import { IUseSettingsFactoryParams } from "../../types/factories"; | ||
import { computed, Ref, ref } from "vue"; | ||
import { SettingClient } from "@vc-shell/api-client"; | ||
@@ -13,3 +13,2 @@ interface IUseSettings { | ||
export default (): IUseSettings => { | ||
const useSettingsFactory = inject<IUseSettingsFactoryParams>("useSettingsFactory"); | ||
const { getAccessToken } = useUser(); | ||
@@ -19,3 +18,5 @@ const logger = useLogger(); | ||
async function getApiClient() { | ||
return useSettingsFactory.getApiClient(await getAccessToken()); | ||
const client = new SettingClient(); | ||
client.setAuthToken(await getAccessToken()); | ||
return client; | ||
} | ||
@@ -22,0 +23,0 @@ |
@@ -1,14 +0,12 @@ | ||
import { computed, Ref, ref, ComputedRef, inject } from "vue"; | ||
import { computed, Ref, ref, ComputedRef } from "vue"; | ||
import ClientOAuth2 from "client-oauth2"; | ||
import { | ||
UserDetail, | ||
SecurityClient, | ||
ResetPasswordConfirmRequest, | ||
SecurityResult, | ||
ValidatePasswordResetTokenRequest, | ||
IdentityResult, | ||
} from "@vc-shell/api-client"; | ||
import { | ||
AuthData, | ||
IUseUserFactoryParams, | ||
RequestPasswordResult, | ||
SignInResult, | ||
} from "../../types"; | ||
import { AuthData, RequestPasswordResult, SignInResult } from "../../types"; | ||
//The Platform Manager uses the same key to store authorization data in the | ||
@@ -26,2 +24,3 @@ //local storage, so we can exchange authorization data between the Platform Manager | ||
}); | ||
const securityClient = new SecurityClient(); | ||
@@ -52,3 +51,2 @@ interface IUseUser { | ||
export default (): IUseUser => { | ||
const useUserFactory = inject<IUseUserFactoryParams>("useUserFactory"); | ||
async function validateToken( | ||
@@ -61,3 +59,5 @@ userId: string, | ||
loading.value = true; | ||
result = await useUserFactory.validateToken(userId, token); | ||
result = await securityClient.validatePasswordResetToken(userId, { | ||
token, | ||
} as ValidatePasswordResetTokenRequest); | ||
} catch (e) { | ||
@@ -72,3 +72,3 @@ //TODO: log error | ||
async function validatePassword(password: string): Promise<IdentityResult> { | ||
return useUserFactory.validatePassword(password); | ||
return securityClient.validatePassword(password); | ||
} | ||
@@ -81,3 +81,6 @@ | ||
): Promise<SecurityResult> { | ||
return useUserFactory.resetPasswordByToken(userId, password, token); | ||
return securityClient.resetPasswordByToken(userId, { | ||
newPassword: password, | ||
token, | ||
} as ResetPasswordConfirmRequest); | ||
} | ||
@@ -131,6 +134,6 @@ | ||
if (token) { | ||
useUserFactory.setAuthToken(token); | ||
securityClient.setAuthToken(token); | ||
try { | ||
loading.value = true; | ||
user.value = await useUserFactory.getCurrentUser(); | ||
user.value = await securityClient.getCurrentUser(); | ||
console.log("[userUsers]: an user details has been loaded", user.value); | ||
@@ -205,3 +208,3 @@ } catch (e) { | ||
loading.value = true; | ||
await useUserFactory.requestPasswordReset(loginOrEmail); | ||
await securityClient.requestPasswordReset(loginOrEmail); | ||
return { succeeded: true }; | ||
@@ -227,7 +230,22 @@ } catch (e) { | ||
loading.value = true; | ||
result = await useUserFactory.changeUserPassword( | ||
oldPassword, | ||
newPassword, | ||
token | ||
const res = await fetch( | ||
"/api/platform/security/currentuser/changepassword", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json-patch+json", | ||
Accept: "text/plain", | ||
authorization: `Bearer ${token}`, | ||
}, | ||
body: JSON.stringify({ | ||
oldPassword, | ||
newPassword, | ||
}), | ||
} | ||
); | ||
if (res.status !== 500) { | ||
result = await res.text().then((response) => { | ||
return JSON.parse(response); | ||
}); | ||
} | ||
} catch (e) { | ||
@@ -234,0 +252,0 @@ return { succeeded: false, errors: [e.message] } as SecurityResult; |
@@ -1,7 +0,1 @@ | ||
import { | ||
IUseUserFactoryParams, | ||
IUseNotificationsFactoryParams, | ||
IUseSettingsFactoryParams, | ||
} from "./factories"; | ||
export interface AuthData { | ||
@@ -27,7 +21,1 @@ accessToken?: string; | ||
} | ||
export type { | ||
IUseUserFactoryParams, | ||
IUseNotificationsFactoryParams, | ||
IUseSettingsFactoryParams, | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
1291363
1486
5
Updated@vc-shell/api-client@^1.0.37