Socket
Socket
Sign inDemoInstall

mongodb

Package Overview
Dependencies
10
Maintainers
8
Versions
518
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.5.0-dev.20240405.sha.ce55ca9 to 6.5.0-dev.20240406.sha.62ea94b

6

lib/cmap/connection.js

@@ -423,3 +423,7 @@ "use strict";

if (!autoEncrypter) {
throw new error_1.MongoMissingDependencyError('No AutoEncrypter available for encryption');
// TODO(NODE-6065): throw a MongoRuntimeError in Node V7
// @ts-expect-error No cause provided because there is no underlying error.
throw new error_1.MongoMissingDependencyError('No AutoEncrypter available for encryption', {
dependencyName: 'n/a'
});
}

@@ -426,0 +430,0 @@ const serverWireVersion = (0, utils_1.maxWireVersion)(this);

57

lib/deps.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMongoDBClientEncryption = exports.aws4 = exports.getSocks = exports.getSnappy = exports.getGcpMetadata = exports.getAwsCredentialProvider = exports.getZstdLibrary = exports.ZStandard = exports.getKerberos = exports.Kerberos = void 0;
exports.getMongoDBClientEncryption = exports.aws4 = exports.getSocks = exports.getSnappy = exports.getGcpMetadata = exports.getAwsCredentialProvider = exports.getZstdLibrary = exports.getKerberos = void 0;
const error_1 = require("./error");

@@ -19,23 +19,23 @@ function makeErrorModule(error) {

}
exports.Kerberos = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `kerberos` not found. Please install it to enable kerberos authentication'));
function getKerberos() {
let kerberos;
try {
// Ensure you always wrap an optional require in the try block NODE-3199
exports.Kerberos = require('kerberos');
return exports.Kerberos;
kerberos = require('kerberos');
}
catch {
return exports.Kerberos;
catch (error) {
kerberos = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `kerberos` not found. Please install it to enable kerberos authentication', { cause: error, dependencyName: 'kerberos' }));
}
return kerberos;
}
exports.getKerberos = getKerberos;
exports.ZStandard = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression'));
function getZstdLibrary() {
let ZStandard;
try {
exports.ZStandard = require('@mongodb-js/zstd');
return exports.ZStandard;
ZStandard = require('@mongodb-js/zstd');
}
catch {
return exports.ZStandard;
catch (error) {
ZStandard = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression', { cause: error, dependencyName: 'zstd' }));
}
return ZStandard;
}

@@ -49,5 +49,5 @@ exports.getZstdLibrary = getZstdLibrary;

}
catch {
catch (error) {
return makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `@aws-sdk/credential-providers` not found.' +
' Please install it to enable getting aws credentials via the official sdk.'));
' Please install it to enable getting aws credentials via the official sdk.', { cause: error, dependencyName: '@aws-sdk/credential-providers' }));
}

@@ -62,5 +62,5 @@ }

}
catch {
catch (error) {
return makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `gcp-metadata` not found.' +
' Please install it to enable getting gcp credentials via the official sdk.'));
' Please install it to enable getting gcp credentials via the official sdk.', { cause: error, dependencyName: 'gcp-metadata' }));
}

@@ -75,4 +75,4 @@ }

}
catch (cause) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `snappy` not found. Please install it to enable snappy compression', { cause });
catch (error) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `snappy` not found. Please install it to enable snappy compression', { cause: error, dependencyName: 'snappy' });
return { kModuleError };

@@ -88,4 +88,4 @@ }

}
catch (cause) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `socks` not found. Please install it to connections over a SOCKS5 proxy', { cause });
catch (error) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `socks` not found. Please install it to connections over a SOCKS5 proxy', { cause: error, dependencyName: 'socks' });
return { kModuleError };

@@ -95,8 +95,13 @@ }

exports.getSocks = getSocks;
exports.aws4 = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `aws4` not found. Please install it to enable AWS authentication'));
try {
// Ensure you always wrap an optional require in the try block NODE-3199
exports.aws4 = require('aws4');
exports.aws4 = loadAws4();
function loadAws4() {
let aws4;
try {
aws4 = require('aws4');
}
catch (error) {
aws4 = makeErrorModule(new error_1.MongoMissingDependencyError('Optional module `aws4` not found. Please install it to enable AWS authentication', { cause: error, dependencyName: 'aws4' }));
}
return aws4;
}
catch { } // eslint-disable-line
/** A utility function to get the instance of mongodb-client-encryption, if it exists. */

@@ -111,4 +116,4 @@ function getMongoDBClientEncryption() {

}
catch (cause) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `mongodb-client-encryption` not found. Please install it to use auto encryption or ClientEncryption.', { cause });
catch (error) {
const kModuleError = new error_1.MongoMissingDependencyError('Optional module `mongodb-client-encryption` not found. Please install it to use auto encryption or ClientEncryption.', { cause: error, dependencyName: 'mongodb-client-encryption' });
return { kModuleError };

@@ -115,0 +120,0 @@ }

@@ -106,3 +106,6 @@ "use strict";

throw new error_1.MongoMissingDependencyError('Auto-encryption requested, but the module is not installed. ' +
'Please add `mongodb-client-encryption` as a dependency of your project');
'Please add `mongodb-client-encryption` as a dependency of your project', {
cause: mongodbClientEncryption['kModuleError'],
dependencyName: 'mongodb-client-encryption'
});
}

@@ -109,0 +112,0 @@ }

@@ -925,4 +925,5 @@ "use strict";

**/
constructor(message, options = {}) {
constructor(message, options) {
super(message, options);
this.dependencyName = options.dependencyName;
}

@@ -929,0 +930,0 @@ get name() {

{
"name": "mongodb",
"version": "6.5.0-dev.20240405.sha.ce55ca9",
"version": "6.5.0-dev.20240406.sha.62ea94b",
"description": "The official MongoDB driver for Node.js",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -39,3 +39,3 @@ import * as dns from 'dns';

let krb: typeof Kerberos;
let krb: Kerberos;

@@ -42,0 +42,0 @@ export class GSSAPI extends AuthProvider {

@@ -698,3 +698,7 @@ import { type Readable, Transform, type TransformCallback } from 'stream';

if (!autoEncrypter) {
throw new MongoMissingDependencyError('No AutoEncrypter available for encryption');
// TODO(NODE-6065): throw a MongoRuntimeError in Node V7
// @ts-expect-error No cause provided because there is no underlying error.
throw new MongoMissingDependencyError('No AutoEncrypter available for encryption', {
dependencyName: 'n/a'
});
}

@@ -701,0 +705,0 @@

@@ -48,3 +48,3 @@ import { promisify } from 'util';

let zstd: typeof ZStandard;
let zstd: ZStandard;
let Snappy: SnappyLib | null = null;

@@ -51,0 +51,0 @@ function loadSnappy() {

@@ -21,17 +21,18 @@ /* eslint-disable @typescript-eslint/no-var-requires */

export let Kerberos: typeof import('kerberos') | { kModuleError: MongoMissingDependencyError } =
makeErrorModule(
new MongoMissingDependencyError(
'Optional module `kerberos` not found. Please install it to enable kerberos authentication'
)
);
export type Kerberos = typeof import('kerberos') | { kModuleError: MongoMissingDependencyError };
export function getKerberos(): typeof Kerberos | { kModuleError: MongoMissingDependencyError } {
export function getKerberos(): Kerberos {
let kerberos: Kerberos;
try {
// Ensure you always wrap an optional require in the try block NODE-3199
Kerberos = require('kerberos');
return Kerberos;
} catch {
return Kerberos;
kerberos = require('kerberos');
} catch (error) {
kerberos = makeErrorModule(
new MongoMissingDependencyError(
'Optional module `kerberos` not found. Please install it to enable kerberos authentication',
{ cause: error, dependencyName: 'kerberos' }
)
);
}
return kerberos;
}

@@ -61,16 +62,18 @@

export let ZStandard: ZStandardLib | { kModuleError: MongoMissingDependencyError } =
makeErrorModule(
new MongoMissingDependencyError(
'Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression'
)
);
export type ZStandard = ZStandardLib | { kModuleError: MongoMissingDependencyError };
export function getZstdLibrary(): typeof ZStandard | { kModuleError: MongoMissingDependencyError } {
export function getZstdLibrary(): ZStandardLib | { kModuleError: MongoMissingDependencyError } {
let ZStandard: ZStandardLib | { kModuleError: MongoMissingDependencyError };
try {
ZStandard = require('@mongodb-js/zstd');
return ZStandard;
} catch {
return ZStandard;
} catch (error) {
ZStandard = makeErrorModule(
new MongoMissingDependencyError(
'Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression',
{ cause: error, dependencyName: 'zstd' }
)
);
}
return ZStandard;
}

@@ -105,7 +108,8 @@

return credentialProvider;
} catch {
} catch (error) {
return makeErrorModule(
new MongoMissingDependencyError(
'Optional module `@aws-sdk/credential-providers` not found.' +
' Please install it to enable getting aws credentials via the official sdk.'
' Please install it to enable getting aws credentials via the official sdk.',
{ cause: error, dependencyName: '@aws-sdk/credential-providers' }
)

@@ -126,7 +130,8 @@ );

return credentialProvider;
} catch {
} catch (error) {
return makeErrorModule(
new MongoMissingDependencyError(
'Optional module `gcp-metadata` not found.' +
' Please install it to enable getting gcp credentials via the official sdk.'
' Please install it to enable getting gcp credentials via the official sdk.',
{ cause: error, dependencyName: 'gcp-metadata' }
)

@@ -157,6 +162,6 @@ );

return value;
} catch (cause) {
} catch (error) {
const kModuleError = new MongoMissingDependencyError(
'Optional module `snappy` not found. Please install it to enable snappy compression',
{ cause }
{ cause: error, dependencyName: 'snappy' }
);

@@ -192,6 +197,6 @@ return { kModuleError };

return value;
} catch (cause) {
} catch (error) {
const kModuleError = new MongoMissingDependencyError(
'Optional module `socks` not found. Please install it to connections over a SOCKS5 proxy',
{ cause }
{ cause: error, dependencyName: 'socks' }
);

@@ -243,13 +248,20 @@ return { kModuleError };

export let aws4: AWS4 | { kModuleError: MongoMissingDependencyError } = makeErrorModule(
new MongoMissingDependencyError(
'Optional module `aws4` not found. Please install it to enable AWS authentication'
)
);
export const aws4: AWS4 | { kModuleError: MongoMissingDependencyError } = loadAws4();
try {
// Ensure you always wrap an optional require in the try block NODE-3199
aws4 = require('aws4');
} catch {} // eslint-disable-line
function loadAws4() {
let aws4: AWS4 | { kModuleError: MongoMissingDependencyError };
try {
aws4 = require('aws4');
} catch (error) {
aws4 = makeErrorModule(
new MongoMissingDependencyError(
'Optional module `aws4` not found. Please install it to enable AWS authentication',
{ cause: error, dependencyName: 'aws4' }
)
);
}
return aws4;
}
/** A utility function to get the instance of mongodb-client-encryption, if it exists. */

@@ -266,6 +278,6 @@ export function getMongoDBClientEncryption():

mongodbClientEncryption = require('mongodb-client-encryption');
} catch (cause) {
} catch (error) {
const kModuleError = new MongoMissingDependencyError(
'Optional module `mongodb-client-encryption` not found. Please install it to use auto encryption or ClientEncryption.',
{ cause }
{ cause: error, dependencyName: 'mongodb-client-encryption' }
);

@@ -272,0 +284,0 @@ return { kModuleError };

@@ -131,3 +131,7 @@ import { callbackify } from 'util';

'Auto-encryption requested, but the module is not installed. ' +
'Please add `mongodb-client-encryption` as a dependency of your project'
'Please add `mongodb-client-encryption` as a dependency of your project',
{
cause: mongodbClientEncryption['kModuleError'],
dependencyName: 'mongodb-client-encryption'
}
);

@@ -134,0 +138,0 @@ }

@@ -1011,2 +1011,7 @@ import type { Document } from './bson';

export class MongoMissingDependencyError extends MongoAPIError {
dependencyName: string;
/** @remarks This property is assigned in the `Error` constructor. */
declare cause: Error;
/**

@@ -1023,4 +1028,5 @@ * **Do not use this constructor!**

**/
constructor(message: string, options: { cause?: Error } = {}) {
constructor(message: string, options: { cause: Error; dependencyName: string }) {
super(message, options);
this.dependencyName = options.dependencyName;
}

@@ -1027,0 +1033,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc