From 8c2e1ba0489b82cbc021c3dae6de9f9543ed3dc7 Mon Sep 17 00:00:00 2001 From: duchm Date: Mon, 7 Aug 2023 13:25:20 +0700 Subject: [PATCH] chore: bump yarn.lock + remove unused code --- package.json | 7 +- src/renderer/components/user/AddEditUser.vue | 396 ----- .../components/user/AddEditUserGroups.vue | 122 -- src/renderer/components/user/AddFamily.vue | 113 -- .../core/services/notifications.service.ts | 203 +-- src/renderer/pages/contact.vue | 2 +- src/renderer/pages/index.vue | 15 +- src/renderer/utils/common.js | 41 - yarn.lock | 1460 ++++++----------- 9 files changed, 508 insertions(+), 1851 deletions(-) delete mode 100644 src/renderer/components/user/AddEditUser.vue delete mode 100644 src/renderer/components/user/AddEditUserGroups.vue delete mode 100644 src/renderer/components/user/AddFamily.vue diff --git a/package.json b/package.json index 24f89037..07989678 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "@xpda-dev/electron-builder": "^0.2.1", "@xpda-dev/electron-launcher": "^0.3.0", "@xpda-dev/webpack-step": "^0.1.2", - "browser-env": "3.3.0", "cross-env": "7.0.3", "deepmerge": "4.2.2", "electron": "12.0.4", @@ -51,7 +50,7 @@ "eslint": "7.24.0", "eslint-friendly-formatter": "4.0.1", "eslint-loader": "4.0.2", - "node-sass": "^6.0.1", + "node-sass": "^9.0.0", "postcss": "^8.2.10", "sass-loader": "^10.1.1", "vue-notion": "^1.4.3", @@ -60,8 +59,6 @@ }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.2.0", - "@microsoft/signalr": "^5.0.5", - "@microsoft/signalr-protocol-msgpack": "^5.0.5", "@notionhq/client": "^1.0.4", "@nuxtjs/axios": "^5.13.6", "@nuxtjs/feed": "^2.0.0", @@ -98,12 +95,12 @@ "papaparse": "^5.3.1", "prismjs": "^1.28.0", "qrcode": "^1.5.1", - "read-excel-file": "^5.4.4", "shepherd.js": "^10.0.1", "slugify": "^1.6.5", "sweetalert2": "^10.16.7", "tldjs": "^2.3.1", "totp-generator": "^0.0.14", + "uuid": "^9.0.0", "valid-url": "^1.0.9", "vee-validate": "^3.4.8", "vue-async-computed": "^3.9.0", diff --git a/src/renderer/components/user/AddEditUser.vue b/src/renderer/components/user/AddEditUser.vue deleted file mode 100644 index 526abe02..00000000 --- a/src/renderer/components/user/AddEditUser.vue +++ /dev/null @@ -1,396 +0,0 @@ - - - diff --git a/src/renderer/components/user/AddEditUserGroups.vue b/src/renderer/components/user/AddEditUserGroups.vue deleted file mode 100644 index 34ac5c20..00000000 --- a/src/renderer/components/user/AddEditUserGroups.vue +++ /dev/null @@ -1,122 +0,0 @@ - - - diff --git a/src/renderer/components/user/AddFamily.vue b/src/renderer/components/user/AddFamily.vue deleted file mode 100644 index da5ba3ab..00000000 --- a/src/renderer/components/user/AddFamily.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - diff --git a/src/renderer/core/services/notifications.service.ts b/src/renderer/core/services/notifications.service.ts index 3ad8fb71..93561160 100644 --- a/src/renderer/core/services/notifications.service.ts +++ b/src/renderer/core/services/notifications.service.ts @@ -1,7 +1,3 @@ -import * as signalR from '@microsoft/signalr' -import * as signalRMsgPack from '@microsoft/signalr-protocol-msgpack' - -import { NotificationType } from '../enums/notificationType' import { ApiService } from '../abstractions/api.service' import { AppIdService } from '../abstractions/appId.service' @@ -12,15 +8,7 @@ import { SyncService } from '../abstractions/sync.service' import { UserService } from '../abstractions/user.service' import { VaultTimeoutService } from '../abstractions/vaultTimeout.service' -import { - NotificationResponse, - SyncCipherNotification, - SyncFolderNotification, - SyncSendNotification -} from '../models/response/notificationResponse' - export class NotificationsService implements NotificationsServiceAbstraction { - private signalrConnection: signalR.HubConnection private url: string private connected = false private inited = false @@ -38,205 +26,18 @@ export class NotificationsService implements NotificationsServiceAbstraction { ) {} async init (environmentService: EnvironmentService): Promise { - this.inited = false - this.url = 'https://api.locker.io' - if (environmentService.notificationsUrl != null) { - this.url = environmentService.notificationsUrl - } else if (environmentService.baseUrl != null) { - this.url = environmentService.baseUrl + '/notifications' - } - - // Set notifications server URL to `https://-` to effectively disable communication - // with the notifications server from the client app - if (this.url === 'https://-') { - return - } - - if (this.signalrConnection != null) { - this.signalrConnection.off('ReceiveMessage') - this.signalrConnection.off('Heartbeat') - await this.signalrConnection.stop() - this.connected = false - this.signalrConnection = null - } - - this.signalrConnection = new signalR.HubConnectionBuilder() - .withUrl(this.url + '/hub', { - accessTokenFactory: () => this.apiService.getActiveBearerToken(), - skipNegotiation: true, - transport: signalR.HttpTransportType.WebSockets - }) - .withHubProtocol( - new signalRMsgPack.MessagePackHubProtocol() as signalR.IHubProtocol - ) - // .configureLogging(signalR.LogLevel.Trace) - .build() - this.signalrConnection.on('ReceiveMessage', (data: any) => - this.processNotification(new NotificationResponse(data)) - ) - this.signalrConnection.on('Heartbeat', (data: any) => { - /* console.log('Heartbeat!'); */ - }) - this.signalrConnection.onclose(() => { - this.connected = false - this.reconnect(true) - }) - this.inited = true - if (await this.isAuthedAndUnlocked()) { - await this.reconnect(false) - } } async updateConnection (sync = false): Promise { - if (!this.inited) { - return - } - try { - if (await this.isAuthedAndUnlocked()) { - await this.reconnect(sync) - } else { - await this.signalrConnection.stop() - } - } catch (e) { - this.logService.error(e.toString()) - } - } - - async reconnectFromActivity (): Promise { - this.inactive = false - if (this.inited && !this.connected) { - await this.reconnect(true) - } - } - async disconnectFromInactivity (): Promise { - this.inactive = true - if (this.inited && this.connected) { - await this.signalrConnection.stop() - } - } - - private async processNotification (notification: NotificationResponse) { - const appId = await this.appIdService.getAppId() - if (notification == null || notification.contextId === appId) { - return - } - - const isAuthenticated = await this.userService.isAuthenticated() - const payloadUserId = - notification.payload.userId || notification.payload.UserId - const myUserId = await this.userService.getUserId() - if ( - isAuthenticated && - payloadUserId != null && - payloadUserId !== myUserId - ) { - return - } - - switch (notification.type) { - case NotificationType.SyncCipherCreate: - case NotificationType.SyncCipherUpdate: - await this.syncService.syncUpsertCipher( - notification.payload as SyncCipherNotification, - notification.type === NotificationType.SyncCipherUpdate - ) - break - case NotificationType.SyncCipherDelete: - case NotificationType.SyncLoginDelete: - await this.syncService.syncDeleteCipher( - notification.payload as SyncCipherNotification - ) - break - case NotificationType.SyncFolderCreate: - case NotificationType.SyncFolderUpdate: - await this.syncService.syncUpsertFolder( - notification.payload as SyncFolderNotification, - notification.type === NotificationType.SyncFolderUpdate - ) - break - case NotificationType.SyncFolderDelete: - await this.syncService.syncDeleteFolder( - notification.payload as SyncFolderNotification - ) - break - case NotificationType.SyncVault: - case NotificationType.SyncCiphers: - case NotificationType.SyncSettings: - if (isAuthenticated) { - await this.syncService.fullSync(false) - } - break - case NotificationType.SyncOrgKeys: - if (isAuthenticated) { - await this.apiService.refreshIdentityToken() - await this.syncService.fullSync(true) - // Stop so a reconnect can be made - await this.signalrConnection.stop() - } - break - case NotificationType.LogOut: - if (isAuthenticated) { - this.logoutCallback() - } - break - case NotificationType.SyncSendCreate: - case NotificationType.SyncSendUpdate: - await this.syncService.syncUpsertSend( - notification.payload as SyncSendNotification, - notification.type === NotificationType.SyncSendUpdate - ) - break - case NotificationType.SyncSendDelete: - await this.syncService.syncDeleteSend( - notification.payload as SyncSendNotification - ) - default: - break - } } - private async reconnect (sync: boolean) { - if (this.reconnectTimer != null) { - clearTimeout(this.reconnectTimer) - this.reconnectTimer = null - } - if (this.connected || !this.inited || this.inactive) { - return - } - const authedAndUnlocked = await this.isAuthedAndUnlocked() - if (!authedAndUnlocked) { - return - } - - try { - await this.signalrConnection.start() - this.connected = true - if (sync) { - await this.syncService.fullSync(false) - } - } catch {} + async reconnectFromActivity (): Promise { - if (!this.connected) { - this.reconnectTimer = setTimeout( - () => this.reconnect(sync), - this.random(120000, 300000) - ) - } } - private async isAuthedAndUnlocked () { - if (await this.userService.isAuthenticated()) { - const locked = await this.vaultTimeoutService.isLocked() - return !locked - } - return false - } + async disconnectFromInactivity (): Promise { - private random (min: number, max: number) { - min = Math.ceil(min) - max = Math.floor(max) - return Math.floor(Math.random() * (max - min + 1)) + min } } diff --git a/src/renderer/pages/contact.vue b/src/renderer/pages/contact.vue index 74c29eee..7a3db72c 100644 --- a/src/renderer/pages/contact.vue +++ b/src/renderer/pages/contact.vue @@ -109,7 +109,7 @@