You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1012 B
TypeScript
33 lines
1012 B
TypeScript
import { WorkerInterface } from '../worker_interface';
|
|
import { join } from 'path';
|
|
import { getAppRootPath } from '../../node/getRootPath';
|
|
|
|
let utilWorkerInterface: WorkerInterface | undefined;
|
|
|
|
type WorkerAllowedFunctionName =
|
|
| 'arrayBufferToStringBase64'
|
|
| 'decryptAttachmentBufferNode'
|
|
| 'encryptAttachmentBufferNode'
|
|
| 'DecryptAESGCM'
|
|
| 'fromBase64ToArrayBuffer'
|
|
| 'verifyAllSignatures'
|
|
| 'encryptForPubkey';
|
|
|
|
export const internalCallUtilsWorker = async (
|
|
fnName: WorkerAllowedFunctionName,
|
|
...args: any
|
|
): Promise<any> => {
|
|
if (!utilWorkerInterface) {
|
|
const utilWorkerPath = join(getAppRootPath(), 'ts', 'webworker', 'workers', 'util.worker.js');
|
|
utilWorkerInterface = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000); //{ type: 'module' }
|
|
}
|
|
return utilWorkerInterface?.callWorker(fnName, ...args);
|
|
};
|
|
|
|
export const callUtilsWorker = async (
|
|
fnName: WorkerAllowedFunctionName,
|
|
...args: any
|
|
): Promise<any> => {
|
|
return internalCallUtilsWorker(fnName, ...args);
|
|
};
|