diff --git a/packages/cli-repl/src/crypt-library-paths.ts b/packages/cli-repl/src/crypt-library-paths.ts index 6eebd75e7..d3b1ac1e6 100644 --- a/packages/cli-repl/src/crypt-library-paths.ts +++ b/packages/cli-repl/src/crypt-library-paths.ts @@ -1,16 +1,21 @@ import path from 'path'; import { promises as fs, constants as fsConstants } from 'fs'; import type { MongoshBus } from '@mongosh/types'; +import type { AutoEncryptionOptions } from 'mongodb'; -export const SHARED_LIBRARY_SUFFIX = +type SharedObjectSuffix = 'so' | 'dylib' | 'dll'; +export const SHARED_LIBRARY_SUFFIX: SharedObjectSuffix = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'; +export type CryptSharedLibPath = NonNullable< + NonNullable['cryptSharedLibPath'] +>; export interface CryptLibraryPathResult { - cryptSharedLibPath?: string; + cryptSharedLibPath?: CryptSharedLibPath; expectedVersion?: { version: bigint; versionStr: string }; } @@ -54,7 +59,10 @@ export async function getCryptLibraryPaths( ), // Location of the shared library in the zip and tgz packages path.resolve(bindir, `mongosh_crypt_v1.${SHARED_LIBRARY_SUFFIX}`), - ]) { + // NB: The types here intentionally mismatch, as we rename the + // library file to avoid conflicts with system installations of + // the crypt_shared library. + ] as CryptSharedLibPath[]) { try { const permissionsMismatch = await ensureMatchingPermissions( libraryCandidate,