From 204b2c7244abb35ad18ab06827823f650e31cc5b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 15 Oct 2025 16:34:24 +0200 Subject: [PATCH 1/2] chore(cli-repl): account for changes to nightly driver typings Specifically, match the stricter typing in https://github.com/mongodb/node-mongodb-native/commit/dab4c7c8279ac1112d99d7ceca505632a45d0787. --- packages/cli-repl/src/crypt-library-paths.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli-repl/src/crypt-library-paths.ts b/packages/cli-repl/src/crypt-library-paths.ts index 6eebd75e71..8ef00b3225 100644 --- a/packages/cli-repl/src/crypt-library-paths.ts +++ b/packages/cli-repl/src/crypt-library-paths.ts @@ -2,7 +2,8 @@ import path from 'path'; import { promises as fs, constants as fsConstants } from 'fs'; import type { MongoshBus } from '@mongosh/types'; -export const SHARED_LIBRARY_SUFFIX = +type SharedObjectSuffix = 'so' | 'dylib' | 'dll'; +export const SHARED_LIBRARY_SUFFIX: SharedObjectSuffix = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' @@ -10,7 +11,7 @@ export const SHARED_LIBRARY_SUFFIX = : 'so'; export interface CryptLibraryPathResult { - cryptSharedLibPath?: string; + cryptSharedLibPath?: `${string}mongo_crypt_v${number}.${SharedObjectSuffix}`; expectedVersion?: { version: bigint; versionStr: string }; } @@ -54,7 +55,7 @@ export async function getCryptLibraryPaths( ), // Location of the shared library in the zip and tgz packages path.resolve(bindir, `mongosh_crypt_v1.${SHARED_LIBRARY_SUFFIX}`), - ]) { + ] as Array<`${string}mongo_crypt_v1.${SharedObjectSuffix}`>) { try { const permissionsMismatch = await ensureMatchingPermissions( libraryCandidate, From 2a4fca470ac47514cbd9bc500e774f9ffa3745fa Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 15 Oct 2025 16:45:35 +0200 Subject: [PATCH 2/2] fixup: more explicit match --- packages/cli-repl/src/crypt-library-paths.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli-repl/src/crypt-library-paths.ts b/packages/cli-repl/src/crypt-library-paths.ts index 8ef00b3225..d3b1ac1e6c 100644 --- a/packages/cli-repl/src/crypt-library-paths.ts +++ b/packages/cli-repl/src/crypt-library-paths.ts @@ -1,6 +1,7 @@ import path from 'path'; import { promises as fs, constants as fsConstants } from 'fs'; import type { MongoshBus } from '@mongosh/types'; +import type { AutoEncryptionOptions } from 'mongodb'; type SharedObjectSuffix = 'so' | 'dylib' | 'dll'; export const SHARED_LIBRARY_SUFFIX: SharedObjectSuffix = @@ -9,9 +10,12 @@ export const SHARED_LIBRARY_SUFFIX: SharedObjectSuffix = : process.platform === 'darwin' ? 'dylib' : 'so'; +export type CryptSharedLibPath = NonNullable< + NonNullable['cryptSharedLibPath'] +>; export interface CryptLibraryPathResult { - cryptSharedLibPath?: `${string}mongo_crypt_v${number}.${SharedObjectSuffix}`; + cryptSharedLibPath?: CryptSharedLibPath; expectedVersion?: { version: bigint; versionStr: string }; } @@ -55,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}`), - ] as Array<`${string}mongo_crypt_v1.${SharedObjectSuffix}`>) { + // 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,