Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/cli-repl/src/crypt-library-paths.ts
Original file line number Diff line number Diff line change
@@ -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<AutoEncryptionOptions['extraOptions']>['cryptSharedLibPath']
>;

export interface CryptLibraryPathResult {
cryptSharedLibPath?: string;
cryptSharedLibPath?: CryptSharedLibPath;
expectedVersion?: { version: bigint; versionStr: string };
}

Expand Down Expand Up @@ -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,
Expand Down