Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb

Package Overview
Dependencies
Maintainers
8
Versions
591
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb - npm Package Compare versions

Comparing version 6.9.0-dev.20240913.sha.8b0f3541 to 6.9.0-dev.20240917.sha.20396e1b

9

lib/cmap/auth/mongo_credentials.js

@@ -17,9 +17,5 @@ "use strict";

}
// Fallback to legacy selection method. If wire version >= 3, use scram-sha-1
if (hello.maxWireVersion >= 3) {
return providers_1.AuthMechanism.MONGODB_SCRAM_SHA1;
}
}
// Default for wireprotocol < 3
return providers_1.AuthMechanism.MONGODB_CR;
// Default auth mechanism for 4.0 and higher.
return providers_1.AuthMechanism.MONGODB_SCRAM_SHA256;
}

@@ -110,3 +106,2 @@ const ALLOWED_ENVIRONMENT_NAMES = [

if ((this.mechanism === providers_1.AuthMechanism.MONGODB_GSSAPI ||
this.mechanism === providers_1.AuthMechanism.MONGODB_CR ||
this.mechanism === providers_1.AuthMechanism.MONGODB_PLAIN ||

@@ -113,0 +108,0 @@ this.mechanism === providers_1.AuthMechanism.MONGODB_SCRAM_SHA1 ||

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OP_MSG = exports.OP_COMPRESSED = exports.OP_DELETE = exports.OP_QUERY = exports.OP_INSERT = exports.OP_UPDATE = exports.OP_REPLY = exports.MIN_SUPPORTED_QE_SERVER_VERSION = exports.MIN_SUPPORTED_QE_WIRE_VERSION = exports.MAX_SUPPORTED_WIRE_VERSION = exports.MIN_SUPPORTED_WIRE_VERSION = exports.MAX_SUPPORTED_SERVER_VERSION = exports.MIN_SUPPORTED_SERVER_VERSION = void 0;
exports.MIN_SUPPORTED_SERVER_VERSION = '3.6';
exports.MIN_SUPPORTED_SERVER_VERSION = '4.0';
exports.MAX_SUPPORTED_SERVER_VERSION = '8.0';
exports.MIN_SUPPORTED_WIRE_VERSION = 6;
exports.MIN_SUPPORTED_WIRE_VERSION = 7;
exports.MAX_SUPPORTED_WIRE_VERSION = 25;

@@ -8,0 +8,0 @@ exports.MIN_SUPPORTED_QE_WIRE_VERSION = 21;

@@ -193,3 +193,3 @@ "use strict";

/**
* Execute an aggregation framework pipeline against the database, needs MongoDB \>= 3.6
* Execute an aggregation framework pipeline against the database.
*

@@ -196,0 +196,0 @@ * @param pipeline - An array of aggregation stages to be executed

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Explain = exports.ExplainVerbosity = void 0;
const error_1 = require("./error");
/** @public */

@@ -14,3 +13,3 @@ exports.ExplainVerbosity = Object.freeze({

class Explain {
constructor(verbosity) {
constructor(verbosity, maxTimeMS) {
if (typeof verbosity === 'boolean') {

@@ -24,11 +23,12 @@ this.verbosity = verbosity

}
this.maxTimeMS = maxTimeMS;
}
static fromOptions(options) {
if (options?.explain == null)
static fromOptions({ explain } = {}) {
if (explain == null)
return;
const explain = options.explain;
if (typeof explain === 'boolean' || typeof explain === 'string') {
return new Explain(explain);
}
throw new error_1.MongoInvalidArgumentError('Field "explain" must be a string or a boolean');
const { verbosity, maxTimeMS } = explain;
return new Explain(verbosity, maxTimeMS);
}

@@ -35,0 +35,0 @@ }

@@ -5,3 +5,2 @@ "use strict";

const gssapi_1 = require("./cmap/auth/gssapi");
const mongocr_1 = require("./cmap/auth/mongocr");
const mongodb_aws_1 = require("./cmap/auth/mongodb_aws");

@@ -20,3 +19,8 @@ const mongodb_oidc_1 = require("./cmap/auth/mongodb_oidc");

[providers_1.AuthMechanism.MONGODB_AWS, () => new mongodb_aws_1.MongoDBAWS()],
[providers_1.AuthMechanism.MONGODB_CR, () => new mongocr_1.MongoCR()],
[
providers_1.AuthMechanism.MONGODB_CR,
() => {
throw new error_1.MongoInvalidArgumentError('MONGODB-CR is no longer a supported auth mechanism in MongoDB 4.0+');
}
],
[providers_1.AuthMechanism.MONGODB_GSSAPI, () => new gssapi_1.GSSAPI()],

@@ -23,0 +27,0 @@ [providers_1.AuthMechanism.MONGODB_OIDC, (workflow) => new mongodb_oidc_1.MongoDBOIDC(workflow)],

@@ -237,6 +237,8 @@ "use strict";

function decorateWithExplain(command, explain) {
if (command.explain) {
return command;
const { verbosity, maxTimeMS } = explain;
const baseCommand = { explain: command, verbosity };
if (typeof maxTimeMS === 'number') {
baseCommand.maxTimeMS = maxTimeMS;
}
return { explain: command, verbosity: explain.verbosity };
return baseCommand;
}

@@ -243,0 +245,0 @@ /**

{
"name": "mongodb",
"version": "6.9.0-dev.20240913.sha.8b0f3541",
"version": "6.9.0-dev.20240917.sha.20396e1b",
"description": "The official MongoDB driver for Node.js",

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

@@ -23,11 +23,6 @@ // Resolves the default auth mechanism according to

}
// Fallback to legacy selection method. If wire version >= 3, use scram-sha-1
if (hello.maxWireVersion >= 3) {
return AuthMechanism.MONGODB_SCRAM_SHA1;
}
}
// Default for wireprotocol < 3
return AuthMechanism.MONGODB_CR;
// Default auth mechanism for 4.0 and higher.
return AuthMechanism.MONGODB_SCRAM_SHA256;
}

@@ -177,3 +172,2 @@

(this.mechanism === AuthMechanism.MONGODB_GSSAPI ||
this.mechanism === AuthMechanism.MONGODB_CR ||
this.mechanism === AuthMechanism.MONGODB_PLAIN ||

@@ -180,0 +174,0 @@ this.mechanism === AuthMechanism.MONGODB_SCRAM_SHA1 ||

@@ -1,4 +0,4 @@

export const MIN_SUPPORTED_SERVER_VERSION = '3.6';
export const MIN_SUPPORTED_SERVER_VERSION = '4.0';
export const MAX_SUPPORTED_SERVER_VERSION = '8.0';
export const MIN_SUPPORTED_WIRE_VERSION = 6;
export const MIN_SUPPORTED_WIRE_VERSION = 7;
export const MAX_SUPPORTED_WIRE_VERSION = 25;

@@ -5,0 +5,0 @@ export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;

import type { Document } from '../bson';
import type { ExplainVerbosityLike } from '../explain';
import type { ExplainCommandOptions, ExplainVerbosityLike } from '../explain';
import type { MongoClient } from '../mongo_client';

@@ -69,3 +69,3 @@ import { AggregateOperation, type AggregateOptions } from '../operations/aggregate';

/** Execute the explain for the cursor */
async explain(verbosity?: ExplainVerbosityLike): Promise<Document> {
async explain(verbosity?: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document> {
return (

@@ -72,0 +72,0 @@ await executeOperation(

import { type Document } from '../bson';
import { CursorResponse } from '../cmap/wire_protocol/responses';
import { MongoInvalidArgumentError, MongoTailableCursorError } from '../error';
import { type ExplainVerbosityLike } from '../explain';
import { type ExplainCommandOptions, type ExplainVerbosityLike } from '../explain';
import type { MongoClient } from '../mongo_client';

@@ -136,3 +136,3 @@ import type { CollationOptions } from '../operations/command';

/** Execute the explain for the cursor */
async explain(verbosity?: ExplainVerbosityLike): Promise<Document> {
async explain(verbosity?: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document> {
return (

@@ -139,0 +139,0 @@ await executeOperation(

@@ -282,3 +282,3 @@ import { Admin } from './admin';

/**
* Execute an aggregation framework pipeline against the database, needs MongoDB \>= 3.6
* Execute an aggregation framework pipeline against the database.
*

@@ -285,0 +285,0 @@ * @param pipeline - An array of aggregation stages to be executed

@@ -1,3 +0,1 @@

import { MongoInvalidArgumentError } from './error';
/** @public */

@@ -16,4 +14,3 @@ export const ExplainVerbosity = Object.freeze({

* For backwards compatibility, true is interpreted as "allPlansExecution"
* and false as "queryPlanner". Prior to server version 3.6, aggregate()
* ignores the verbosity parameter and executes in "queryPlanner".
* and false as "queryPlanner".
* @public

@@ -24,5 +21,41 @@ */

/** @public */
export interface ExplainCommandOptions {
/** The explain verbosity for the command. */
verbosity: ExplainVerbosity;
/** The maxTimeMS setting for the command. */
maxTimeMS?: number;
}
/**
* @public
*
* When set, this configures an explain command. Valid values are boolean (for legacy compatibility,
* see {@link ExplainVerbosityLike}), a string containing the explain verbosity, or an object containing the verbosity and
* an optional maxTimeMS.
*
* Examples of valid usage:
*
* ```typescript
* collection.find({ name: 'john doe' }, { explain: true });
* collection.find({ name: 'john doe' }, { explain: false });
* collection.find({ name: 'john doe' }, { explain: 'queryPlanner' });
* collection.find({ name: 'john doe' }, { explain: { verbosity: 'queryPlanner' } });
* ```
*
* maxTimeMS can be configured to limit the amount of time the server
* spends executing an explain by providing an object:
*
* ```typescript
* // limits the `explain` command to no more than 2 seconds
* collection.find({ name: 'john doe' }, {
* explain: {
* verbosity: 'queryPlanner',
* maxTimeMS: 2000
* }
* });
* ```
*/
export interface ExplainOptions {
/** Specifies the verbosity mode for the explain output. */
explain?: ExplainVerbosityLike;
explain?: ExplainVerbosityLike | ExplainCommandOptions;
}

@@ -32,5 +65,6 @@

export class Explain {
verbosity: ExplainVerbosity;
readonly verbosity: ExplainVerbosity;
readonly maxTimeMS?: number;
constructor(verbosity: ExplainVerbosityLike) {
private constructor(verbosity: ExplainVerbosityLike, maxTimeMS?: number) {
if (typeof verbosity === 'boolean') {

@@ -43,8 +77,9 @@ this.verbosity = verbosity

}
this.maxTimeMS = maxTimeMS;
}
static fromOptions(options?: ExplainOptions): Explain | undefined {
if (options?.explain == null) return;
static fromOptions({ explain }: ExplainOptions = {}): Explain | undefined {
if (explain == null) return;
const explain = options.explain;
if (typeof explain === 'boolean' || typeof explain === 'string') {

@@ -54,4 +89,5 @@ return new Explain(explain);

throw new MongoInvalidArgumentError('Field "explain" must be a string or a boolean');
const { verbosity, maxTimeMS } = explain;
return new Explain(verbosity, maxTimeMS);
}
}

@@ -371,4 +371,9 @@ import { Admin } from './admin';

export type { AnyError, ErrorDescription, MongoNetworkErrorOptions } from './error';
export type { Explain, ExplainOptions, ExplainVerbosityLike } from './explain';
export type {
Explain,
ExplainCommandOptions,
ExplainOptions,
ExplainVerbosityLike
} from './explain';
export type {
GridFSBucketReadStreamOptions,

@@ -375,0 +380,0 @@ GridFSBucketReadStreamOptionsWithRevision,

import { type AuthProvider } from './cmap/auth/auth_provider';
import { GSSAPI } from './cmap/auth/gssapi';
import { type AuthMechanismProperties } from './cmap/auth/mongo_credentials';
import { MongoCR } from './cmap/auth/mongocr';
import { MongoDBAWS } from './cmap/auth/mongodb_aws';

@@ -19,3 +18,10 @@ import { MongoDBOIDC, OIDC_WORKFLOWS, type Workflow } from './cmap/auth/mongodb_oidc';

[AuthMechanism.MONGODB_AWS, () => new MongoDBAWS()],
[AuthMechanism.MONGODB_CR, () => new MongoCR()],
[
AuthMechanism.MONGODB_CR,
() => {
throw new MongoInvalidArgumentError(
'MONGODB-CR is no longer a supported auth mechanism in MongoDB 4.0+'
);
}
],
[AuthMechanism.MONGODB_GSSAPI, () => new GSSAPI()],

@@ -22,0 +28,0 @@ [AuthMechanism.MONGODB_OIDC, (workflow?: Workflow) => new MongoDBOIDC(workflow)],

@@ -28,3 +28,3 @@ import * as crypto from 'crypto';

} from './error';
import type { Explain } from './explain';
import type { Explain, ExplainVerbosity } from './explain';
import type { MongoClient } from './mongo_client';

@@ -255,8 +255,19 @@ import type { CommandOperationOptions, OperationParent } from './operations/command';

*/
export function decorateWithExplain(command: Document, explain: Explain): Document {
if (command.explain) {
return command;
export function decorateWithExplain(
command: Document,
explain: Explain
): {
explain: Document;
verbosity: ExplainVerbosity;
maxTimeMS?: number;
} {
type ExplainCommand = ReturnType<typeof decorateWithExplain>;
const { verbosity, maxTimeMS } = explain;
const baseCommand: ExplainCommand = { explain: command, verbosity };
if (typeof maxTimeMS === 'number') {
baseCommand.maxTimeMS = maxTimeMS;
}
return { explain: command, verbosity: explain.verbosity };
return baseCommand;
}

@@ -263,0 +274,0 @@

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

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 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc