TagSpaces is an offline, open source, document manager with tagging support
Fix s3 encryption issues (#2185)
Stanimir7cd83c646c97
diff --git a/package-lock.json b/package-lock.jsonindex 02b64d8b4..f4b514c3d 100644--- a/package-lock.json+++ b/package-lock.json@@ -198,7 +198,7 @@"yarn": "please-use-npm"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.72"+ "@tagspacespro/tagspacespro": "5.0.73"}},"node_modules/@adobe/css-tools": {@@ -17224,9 +17224,9 @@}},"node_modules/@tagspacespro/tagspacespro": {- "version": "5.0.72",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.72/18a8aead5c506ee4af98b1e4cdf7b3fa87ac5041",- "integrity": "sha512-R1JZUhG4d55++9PjhINj0ed4pgmBhgcxvNPcHvA3Ww/xvEW1VFajHwFBcyhAYFLmcbf1oAd9QDJQtKdtLGLz2w==",+ "version": "5.0.73",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.73/8adaa04d9961e0a57a659b45d43794e5397cda72",+ "integrity": "sha512-AM2arO0OIi7Im/irt8U4hYaJb7LuI5fgpx4oqPCjvZdN9x9Wp0H1alTMvAWja1NsWemchVvbTcbuEVx9l4jwWA==","license": "Proprietary","optional": true},diff --git a/src/renderer/components/EntryContainerMenu.tsx b/src/renderer/components/EntryContainerMenu.tsxindex 6be72a086..2d9739a04 100644--- a/src/renderer/components/EntryContainerMenu.tsx+++ b/src/renderer/components/EntryContainerMenu.tsx@@ -73,8 +73,8 @@ function EntryContainerMenu(props: Props) {} = useOpenedEntryContext();const keyBindings = useSelector(getKeyBindingObject);const { currentLocation, readOnlyMode } = useCurrentLocationContext();- const { deleteFile } = useIOActionsContext();- const { showNotification } = useNotificationContext();+ const { deleteFile, downloadFsEntry } = useIOActionsContext();+ //const { showNotification } = useNotificationContext();const desktopMode = useSelector(isDesktopMode);const warningOpeningFilesExternally = useSelector(getWarningOpeningFilesExternally,@@ -138,7 +138,8 @@ function EntryContainerMenu(props: Props) {data-tid="downloadFileTID"aria-label={t('core:downloadFile')}onClick={() => {- if (openedEntry.isEncrypted) {+ downloadFsEntry(openedEntry);+ /*if (openedEntry.isEncrypted) {currentLocation.getFileContentPromise(openedEntry.path, 'arraybuffer').then((arrayBuffer) => {@@ -164,7 +165,7 @@ function EntryContainerMenu(props: Props) {if (downloadResult === -1) {showNotification(t('core:cantDownloadLocalFile'));}- }+ }*/handleClose();}}>diff --git a/src/renderer/components/EntryProperties.tsx b/src/renderer/components/EntryProperties.tsxindex 46d6564db..6ca585e50 100644--- a/src/renderer/components/EntryProperties.tsx+++ b/src/renderer/components/EntryProperties.tsx@@ -550,7 +550,8 @@ function EntryProperties(props: Props) {const isCloudLocation = openedEntry.url && openedEntry.url.length > 5;- const showLinkForDownloading = isCloudLocation && openedEntry.isFile;+ const showLinkForDownloading =+ isCloudLocation && openedEntry.isFile && !openedEntry.isEncrypted;/*const thumbUrl = location.getThumbPath(openedEntry.meta?.thumbPath,diff --git a/src/renderer/components/FileView.tsx b/src/renderer/components/FileView.tsxindex b78aa8800..8ac76db3f 100644--- a/src/renderer/components/FileView.tsx+++ b/src/renderer/components/FileView.tsx@@ -106,31 +106,24 @@ function FileView(props: Props) {extTextColor +extBgndColor;+ const encrypted = openedEntry.isEncrypted ? '&encrypted=true' : '';+ const getParams =+ '/index.html?file=' ++ encodeURIComponent(+ openedEntry.url ? openedEntry.url : openedEntry.path,+ ) ++ locale ++ theming ++ extQuery ++ event ++ encrypted;+if (isEditMode && openedEntry.editingExtensionPath) {- return (- openedEntry.editingExtensionPath +- '/index.html?file=' +- encodeURIComponent(- openedEntry.url ? openedEntry.url : openedEntry.path,- ) +- locale +- theming +- extQuery +- event +- '&edit=true'- // '&t=' + openedEntry.lmdt- );+ return openedEntry.editingExtensionPath + getParams + '&edit=true';} else {return (openedEntry.viewingExtensionPath +- '/index.html?file=' +- encodeURIComponent(- openedEntry.url ? openedEntry.url : openedEntry.path,- ) +- locale +- theming +- extQuery +- event ++ getParams +'&t=' +openedEntry.lmdt);diff --git a/src/renderer/components/dialogs/DownloadUrlDialog.tsx b/src/renderer/components/dialogs/DownloadUrlDialog.tsxindex 08d359e4a..9da812310 100644--- a/src/renderer/components/dialogs/DownloadUrlDialog.tsx+++ b/src/renderer/components/dialogs/DownloadUrlDialog.tsx@@ -68,7 +68,7 @@ function DownloadUrlDialog(props: Props) {const fullScreen = useMediaQuery(theme.breakpoints.down('md'));const { currentLocation, getFirstRWLocation } = useCurrentLocationContext();const { setReflectActions } = useEditedEntryContext();- const { downloadFile } = useIOActionsContext();+ const { downloadUrl } = useIOActionsContext();const { showNotification } = useNotificationContext();const { openFileUploadDialog } = useFileUploadDialogContext();const dispatch: AppDispatch = useDispatch();@@ -117,7 +117,7 @@ function DownloadUrlDialog(props: Props) {if (!location.haveObjectStoreSupport() && AppConfig.isElectron) {dispatch(AppActions.resetProgress());openFileUploadDialog();- downloadFile(+ downloadUrl(fileUrl.current,targetDirectoryPath + '/' + decodeURIComponent(fileName),onUploadProgress,diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsxindex d7fa34459..89e5ee45f 100644--- a/src/renderer/components/menus/FileMenu.tsx+++ b/src/renderer/components/menus/FileMenu.tsx@@ -41,7 +41,6 @@ import {} from '@tagspaces/tagspaces-common/paths';import {createNewInstance,- downloadFile,getRelativeEntryPath,openDirectoryMessage,} from '-/services/utils-io';@@ -79,6 +78,9 @@ interface Props {openMoveCopyFilesDialog: () => void;openShareFilesDialog?: () => void;openAddRemoveTagsDialog: () => void;+ /**+ * @deprecated use selectedEntries instead+ */selectedFilePath?: string;reorderTop?: () => void;reorderBottom?: () => void;@@ -112,6 +114,7 @@ function FileMenu(props: Props) {openFileNatively,duplicateFile,setFolderBackgroundPromise,+ downloadFsEntry,} = useIOActionsContext();const { openEntry } = useOpenedEntryContext();const { openDirectory, currentLocationPath, getAllPropertiesPromise } =@@ -556,14 +559,25 @@ function FileMenu(props: Props) {key="downloadFileUrl"data-tid="downloadFileUrlTID"onClick={() => {- const downloadResult = downloadFile(+ if (selectedEntries && selectedEntries.length > 0) {+ const fsEntry = selectedEntries[selectedEntries.length - 1];+ currentLocation+ .checkFileEncryptedPromise(fsEntry.path)+ .then((encrypted) => {+ downloadFsEntry({ ...fsEntry, isEncrypted: encrypted });+ });+ }+ /*currentLocation+ .getPropertiesPromise(selectedFilePath)+ .then((fsEntry: TS.FileSystemEntry) => downloadFsEntry(fsEntry));*/+ /*const downloadResult = downloadFile(selectedFilePath,downloadFileUrl.current,currentLocation?.getDirSeparator(),);if (downloadResult === -1) {showNotification(t('core:cantDownloadLocalFile'));- }+ }*/onClose();}}>diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsxindex ba733d976..749a22e48 100644--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx@@ -125,6 +125,7 @@ type DirectoryContentContextData = {getAllPropertiesPromise: (entryPath: string,locationID?: string,+ useEncryption?: boolean,) => Promise<TS.FileSystemEntry>;loadCurrentDirMeta: (directoryPath: string,@@ -1034,10 +1035,11 @@ export const DirectoryContentContextProvider = ({function getAllPropertiesPromise(entryPath: string,locationID: string = undefined,+ useEncryption: boolean = true,): Promise<TS.FileSystemEntry> {const location = locationID ? findLocation(locationID) : currentLocation;return location- .getPropertiesPromise(entryPath)+ .getPropertiesPromise(entryPath, useEncryption).then((entryProps: TS.FileSystemEntry) => {if (entryProps) {if (typeof entryProps === 'boolean') {@@ -1049,7 +1051,7 @@ export const DirectoryContentContextProvider = ({if (!entryProps.isFile) {return getEnhancedDir(entry);}- return getEnhancedFile(entry);+ return getEnhancedFile(entry, useEncryption);}}console.log('Error getting props for ' + entryPath);@@ -1257,6 +1259,7 @@ export const DirectoryContentContextProvider = ({function getEnhancedFile(entry: TS.FileSystemEntry,+ useEncryption: boolean = true,): Promise<TS.FileSystemEntry> {if (!entry) {return Promise.resolve(undefined);@@ -1275,39 +1278,41 @@ export const DirectoryContentContextProvider = ({false,);- return location.checkFileExist(thumbFilePath).then((exist) => {- const metaProps = exist ? { thumbPath: thumbFilePath } : {};+ return location+ .checkFileExist(thumbFilePath, useEncryption)+ .then((exist) => {+ const metaProps = exist ? { thumbPath: thumbFilePath } : {};- const metaFilePath = getMetaFileLocationForFile(- entry.path,- location.getDirSeparator(),- );+ const metaFilePath = getMetaFileLocationForFile(+ entry.path,+ location.getDirSeparator(),+ );- try {- return location- .loadJSONFile(metaFilePath)- .then((meta: TS.FileSystemEntryMeta) => {- if (meta) {+ try {+ return location+ .loadJSONFile(metaFilePath, useEncryption)+ .then((meta: TS.FileSystemEntryMeta) => {+ if (meta) {+ return enhanceEntry(+ { ...entry, meta: { ...meta, ...metaProps } },+ AppConfig.tagDelimiter,+ location.getDirSeparator(),+ );+ }return enhanceEntry(- { ...entry, meta: { ...meta, ...metaProps } },+ { ...entry, meta: { ...metaProps } },AppConfig.tagDelimiter,location.getDirSeparator(),);- }- return enhanceEntry(- { ...entry, meta: { ...metaProps } },- AppConfig.tagDelimiter,- location.getDirSeparator(),- );- });- } catch (e) {- return enhanceEntry(- { ...entry, meta: { ...metaProps } },- AppConfig.tagDelimiter,- location.getDirSeparator(),- );- }- });+ });+ } catch (e) {+ return enhanceEntry(+ { ...entry, meta: { ...metaProps } },+ AppConfig.tagDelimiter,+ location.getDirSeparator(),+ );+ }+ });}function getDirMeta(diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsxindex eb30858dc..8de7ae301 100644--- a/src/renderer/hooks/IOActionsContextProvider.tsx+++ b/src/renderer/hooks/IOActionsContextProvider.tsx@@ -45,6 +45,7 @@ import { actions as AppActions, AppDispatch } from '-/reducers/app';import { useDispatch, useSelector } from 'react-redux';import {cleanMetaData,+ downloadFile,executePromisesInBatches,mergeFsEntryMeta,openDirectoryMessage,@@ -107,11 +108,12 @@ type IOActionsContextData = {locationID: string,onProgress?,) => Promise<boolean>;- downloadFile: (+ downloadUrl: (url: string,targetPath: string,onDownloadProgress?: (progress, abort, fileName?) => void,) => Promise<TS.FileSystemEntry>;+ downloadFsEntry: (fsEntry: TS.FileSystemEntry) => void;uploadFilesAPI: (files: Array<any>,targetPath: string,@@ -227,7 +229,8 @@ export const IOActionsContext = createContext<IOActionsContextData>({moveFiles: undefined,copyDirs: undefined,copyFiles: undefined,- downloadFile: undefined,+ downloadUrl: undefined,+ downloadFsEntry: undefined,uploadFilesAPI: undefined,uploadFiles: undefined,renameDirectory: undefined,@@ -832,7 +835,7 @@ export const IOActionsContextProvider = ({* @param targetPath* @param onDownloadProgress*/- function downloadFile(+ function downloadUrl(url: string,targetPath: string,onDownloadProgress?: (progress, abort, fileName?) => void,@@ -890,6 +893,47 @@ export const IOActionsContextProvider = ({});}+ function downloadFsEntry(fsEntry: TS.FileSystemEntry) {+ const loc = findLocation(fsEntry.locationID);+ if (loc) {+ if (fsEntry.isEncrypted) {+ loc+ .getFileContentPromise(fsEntry.path, 'arraybuffer')+ .then((arrayBuffer) => {+ const url = window.URL || window.webkitURL;+ const openedEntryUrl = url.createObjectURL(new Blob([arrayBuffer]));+ const downloadResult = downloadFile(+ fsEntry.path,+ openedEntryUrl,+ currentLocation?.getDirSeparator(),+ );+ if (downloadResult === -1) {+ showNotification(t('core:cantDownloadLocalFile'));+ }+ });+ } else if (loc.haveObjectStoreSupport()) {+ loc.generateURLforPath(fsEntry.path, 86400).then((url) => {+ const downloadResult = downloadFile(+ fsEntry.path,+ url,+ currentLocation?.getDirSeparator(),+ );+ if (downloadResult === -1) {+ showNotification(t('core:cantDownloadLocalFile'));+ }+ });+ } else {+ const downloadResult = downloadFile(+ fsEntry.path,+ fsEntry.url,+ currentLocation?.getDirSeparator(),+ );+ if (downloadResult === -1) {+ showNotification(t('core:cantDownloadLocalFile'));+ }+ }+ }+ }/*** with HTML5 Files API* @param files@@ -1626,22 +1670,28 @@ export const IOActionsContextProvider = ({}}).catch(() => {- // create new meta id to not be changed -> next time listDirectory will get the same id for the file from meta- const mataData = { id: id };- const metaFilePath = path.endsWith(location.getDirSeparator())- ? getMetaFileLocationForDir(path, location.getDirSeparator())- : getMetaFileLocationForFile(path, location.getDirSeparator());-- return saveTextFilePromise(- { path: metaFilePath, locationID: location.uuid },- JSON.stringify(mataData),- true,- )- .then(() => mataData)- .catch((e) => {- console.error(e);- return mataData;- });+ if (+ path.indexOf(location.getDirSeparator() + AppConfig.metaFolder) === -1+ ) {+ // create new meta id to not be changed -> next time listDirectory will get the same id for the file from meta+ const mataData = { id: id };+ const metaFilePath = path.endsWith(location.getDirSeparator())+ ? getMetaFileLocationForDir(path, location.getDirSeparator())+ : getMetaFileLocationForFile(path, location.getDirSeparator());++ return saveTextFilePromise(+ { path: metaFilePath, locationID: location.uuid },+ JSON.stringify(mataData),+ true,+ )+ .then(() => mataData)+ .catch((e) => {+ console.error(e);+ return mataData;+ });+ } else {+ return { id: id };+ }});}@@ -2200,7 +2250,8 @@ export const IOActionsContextProvider = ({moveFiles,copyDirs,copyFiles,- downloadFile,+ downloadUrl,+ downloadFsEntry,uploadFilesAPI,uploadFiles,renameDirectory,diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsxindex 6b8163863..0052ad6c2 100644--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx@@ -746,23 +746,30 @@ export const OpenedEntryContextProvider = ({}if (entryPath) {- getAllPropertiesPromise(+ const filePath =(locationPath.length > 0 ? locationPath + '/' : '') +- entryPath,- lid,- )- .then((fsEntry: TS.FileSystemEntry) => {- if (fsEntry) {- openFsEntry(fsEntry);- if (options.fullWidth) {- setEntryInFullWidth(true);- }- }- return true;- })- .catch(() =>- showNotification(t('core:invalidLink'), 'warning', true),- );+ entryPath;+ targetLocation+ .checkFileEncryptedPromise(filePath)+ .then((encrypted) => {+ getAllPropertiesPromise(filePath, lid, encrypted)+ .then((fsEntry: TS.FileSystemEntry) => {+ if (fsEntry) {+ openFsEntry(fsEntry);+ if (options.fullWidth) {+ setEntryInFullWidth(true);+ }+ }+ return true;+ })+ .catch(() =>+ showNotification(+ t('core:invalidLink'),+ 'warning',+ true,+ ),+ );+ });}// });} else {diff --git a/src/renderer/perspectives/grid/components/GridCell.tsx b/src/renderer/perspectives/grid/components/GridCell.tsxindex 5056dcc8f..25675e00b 100644--- a/src/renderer/perspectives/grid/components/GridCell.tsx+++ b/src/renderer/perspectives/grid/components/GridCell.tsx@@ -16,8 +16,8 @@**/-import React, { useEffect, useMemo, useReducer, useRef } from 'react';-import { useSelector, useDispatch } from 'react-redux';+import React, { useEffect, useReducer, useRef } from 'react';+import { useSelector } from 'react-redux';import { useTheme } from '@mui/material/styles';import { useTranslation } from 'react-i18next';import Typography from '@mui/material/Typography';@@ -42,6 +42,7 @@ import {import {extractTagsAsObjects,extractTitle,+ getThumbFileLocationForFile,} from '@tagspaces/tagspaces-common/paths';import AppConfig from '-/AppConfig';import {@@ -64,6 +65,7 @@ import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsConimport i18n from '-/services/i18n';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';import useFirstRender from '-/utils/useFirstRender';+import { arrayBufferToDataURL } from '-/utils/dom';export function urlGetDelim(url) {return url.indexOf('?') > 0 ? '&' : '?';@@ -145,28 +147,58 @@ function GridCell(props: Props) {const isSmall = entrySize === 'tiny' || entrySize === 'small';const gridCellLocation = findLocation(fsEntry.locationID);- function setThumbPath(update = true): Promise<boolean> {+ function getThumbUrl() {+ if (gridCellLocation) {+ return gridCellLocation+ .getThumbPath(fsEntry.meta.thumbPath, fsEntry.meta?.lastUpdated)+ .then((tmbPath) => {+ if (tmbPath !== thumbPath.current) {+ thumbPath.current = tmbPath;+ return true;+ }+ return false;+ });+ }+ return Promise.resolve(false);+ }++ function setThumbPath(): Promise<boolean> {if (gridCellLocation && fsEntry.meta) {if (fsEntry.meta.thumbPath) {- return gridCellLocation- .getThumbPath(fsEntry.meta.thumbPath, fsEntry.meta?.lastUpdated)- .then((tmbPath) => {- if (tmbPath !== thumbPath.current) {- thumbPath.current = tmbPath;- if (update) {- forceUpdate();+ if (gridCellLocation.encryptionKey) {+ let thumbFilePath = getThumbFileLocationForFile(+ fsEntry.path,+ gridCellLocation.getDirSeparator(),+ false,+ );+ return gridCellLocation+ .getFileContentPromise(thumbFilePath, 'arraybuffer')+ .then((arrayBuffer) => {+ if (arrayBuffer) {+ return arrayBufferToDataURL(arrayBuffer, 'image/jpeg').then(+ (dataURL) => {+ thumbPath.current = dataURL;+ return true;+ },+ );+ } else {+ return getThumbUrl();}- return true;- }- return false;- });+ });+ } else {+ return getThumbUrl();+ }}}return Promise.resolve(false);}useEffect(() => {- setThumbPath();+ setThumbPath().then((success) => {+ if (success) {+ forceUpdate();+ }+ });}, [fsEntry]);useEffect(() => {@@ -179,7 +211,11 @@ function GridCell(props: Props) {action.action === 'descriptionChange') {fsEntry.meta = { ...action.entry.meta };- setThumbPath(false).then(() => forceUpdate());+ setThumbPath().then((success) => {+ if (success) {+ forceUpdate();+ }+ });}}}diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex 15f7be604..8adf92613 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -293,14 +293,37 @@ export class CommonLocation implements TS.Location {);};- getPropertiesPromise = (path: string): Promise<any> => {+ checkFileEncryptedPromise = (path: string): Promise<boolean> => {+ if (this.ioAPI) {+ if (this.haveObjectStoreSupport() && this.encryptionKey) {+ return this.ioAPI+ .getPropertiesPromise({+ path,+ bucketName: this.bucketName,+ location: this,+ ...(this.encryptionKey && { encryptionKey: this.encryptionKey }),+ })+ .then(+ (fsEntry: TS.FileSystemEntry) =>+ fsEntry && typeof fsEntry !== 'boolean',+ );+ }+ }+ return Promise.resolve(false);+ };++ getPropertiesPromise = (+ path: string,+ useEncryption: boolean = true,+ ): Promise<any> => {if (this.ioAPI) {if (this.haveObjectStoreSupport()) {return this.ioAPI.getPropertiesPromise({path,bucketName: this.bucketName,location: this,- ...(this.encryptionKey && { encryptionKey: this.encryptionKey }),+ ...(this.encryptionKey &&+ useEncryption && { encryptionKey: this.encryptionKey }),});}return this.ioAPI.getPropertiesPromise(path);@@ -310,7 +333,7 @@ export class CommonLocation implements TS.Location {return Promise.reject(new Error('getPropertiesPromise: not implemented'));};- checkFileExist = (file: string): Promise<boolean> => {+ checkFileExist = (file: string, useEncryption = true): Promise<boolean> => {if (file === undefined) {return Promise.resolve(false);}@@ -320,7 +343,8 @@ export class CommonLocation implements TS.Location {path: file,bucketName: this.bucketName,location: this,- ...(this.encryptionKey && { encryptionKey: this.encryptionKey }),+ ...(this.encryptionKey &&+ useEncryption && { encryptionKey: this.encryptionKey }),});} else if (AppConfig.isCordova) {return this.ioAPI.checkFileExist(file);@@ -787,7 +811,11 @@ export class CommonLocation implements TS.Location {);};*/- loadTextFilePromise = (param: any, isPreview?: boolean): Promise<string> => {+ loadTextFilePromise = (+ param: any,+ isPreview?: boolean,+ useEncryption: boolean = true,+ ): Promise<string> => {let filePath = this.getPath(param);try {filePath = decodeURIComponent(filePath);@@ -799,7 +827,8 @@ export class CommonLocation implements TS.Location {path: filePath,bucketName: this.bucketName,location: this,- ...(this.encryptionKey && { encryptionKey: this.encryptionKey }),+ ...(this.encryptionKey &&+ useEncryption && { encryptionKey: this.encryptionKey }),},isPreview,);@@ -868,8 +897,11 @@ export class CommonLocation implements TS.Location {);};- loadJSONFile = (filePath: string): Promise<TS.FileSystemEntryMeta> => {- return this.loadTextFilePromise(filePath)+ loadJSONFile = (+ filePath: string,+ useEncryption: boolean = true,+ ): Promise<TS.FileSystemEntryMeta> => {+ return this.loadTextFilePromise(filePath, undefined, useEncryption).then((jsonContent) => loadJSONString(jsonContent) as TS.FileSystemEntryMeta,)diff --git a/src/renderer/utils/dom.ts b/src/renderer/utils/dom.tsindex 992c18e2a..7d249f577 100644--- a/src/renderer/utils/dom.ts+++ b/src/renderer/utils/dom.ts@@ -100,10 +100,27 @@ export function getBase64Image(imgURL: string) {return canvas.toDataURL('image/png');}-export function arrayBufferToDataURL(arrayBuffer: any, mime: string) {+/*export function arrayBufferToDataURL(arrayBuffer: any, mime: string) {const blob = new Blob([arrayBuffer], { type: mime });const url = window.URL || window.webkitURL;return url.createObjectURL(blob);+}*/++export function arrayBufferToDataURL(+ arrayBuffer: any,+ mime: string,+): Promise<string> {+ return new Promise((resolve) => {+ const blob = new Blob([arrayBuffer], { type: mime });+ const reader = new FileReader();++ reader.onload = function (event) {+ const dataUrl = event.target?.result as string;+ resolve(dataUrl);+ };++ reader.readAsDataURL(blob);+ });}export function dataURLtoBlob(dataURI) {diff --git a/tsconfig.json b/tsconfig.jsonindex a3e52e336..b40fc55ed 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -23,7 +23,9 @@"paths": {"-/*": ["src/renderer/*"],"assets/*": ["assets/*"]- }+ },+ "typeRoots": ["./node_modules/@types"],+ "types": ["node"]},"include": ["src/main/**/*.ts",