Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fileAvailable = (filePath) => {
if (
isInvalidPath(filePath) ||
filePath.endsWith('/') ||
filePath.endsWith('\\')
) {
return `'${filePath}' is not a valid file path`;
}
if (filePath.startsWith('/') || filePath.startsWith('\\')) {
return 'Specify a relative file path';
}
const jsPath = jsExtensionPath(filePath);
if (fs.existsSync(jsPath)) {
const stats = fs.statSync(jsPath);
return stats.isDirectory()
? `'${jsPath}' is a directory`
});
const keyLoader = new PrivateKeyLoader(identity, {
accessTokenProvider,
virgilCrypto,
brainKeyCrypto,
keyEntryStorage,
apiUrl: opts.apiUrl,
});
const cardManager = new CardManager({
cardCrypto,
cardVerifier,
accessTokenProvider,
retryOnUnauthorized: true,
apiUrl: opts.apiUrl,
});
if (isInvalidPath(opts.groupStorageName!)) {
throw new TypeError('`groupStorageName` is not a valid path');
}
mkdirp.sync(opts.groupStorageName!);
const groupStorageLeveldown = leveldown(opts.groupStorageName!);
super({
identity,
virgilCrypto,
cardManager,
accessTokenProvider,
keyEntryStorage,
keyLoader,
groupStorageLeveldown,
});
}