mongodb 6.20.0-dev.20251004.sha.8a67346c → 6.20.0-dev.20251008.sha.cfbada66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/beta.d.ts +7 -137
- package/lib/bulk/common.js +7 -9
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +1 -3
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +2 -3
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/errors.js +3 -1
- package/lib/client-side-encryption/errors.js.map +1 -1
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +3 -1
- package/lib/cmap/wire_protocol/constants.js.map +1 -1
- package/lib/collection.js +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +0 -8
- package/lib/connection_string.js.map +1 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/upload.js +2 -8
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/mongo_types.js +1 -2
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/create_collection.js +0 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/execute_operation.js +3 -1
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/read_preference.js +0 -4
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/topology.js +1 -42
- package/lib/sdam/topology.js.map +1 -1
- package/lib/transactions.js +2 -13
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +0 -14
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +7 -137
- package/package.json +3 -3
- package/src/bulk/common.ts +9 -11
- package/src/change_stream.ts +1 -17
- package/src/client-side-encryption/auto_encrypter.ts +4 -10
- package/src/client-side-encryption/client_encryption.ts +4 -5
- package/src/client-side-encryption/errors.ts +3 -0
- package/src/cmap/connection.ts +1 -0
- package/src/cmap/connection_pool.ts +0 -9
- package/src/cmap/handshake/client_metadata.ts +0 -13
- package/src/cmap/wire_protocol/constants.ts +2 -0
- package/src/collection.ts +1 -1
- package/src/connection_string.ts +0 -10
- package/src/gridfs/download.ts +0 -4
- package/src/gridfs/upload.ts +0 -22
- package/src/index.ts +1 -4
- package/src/mongo_types.ts +1 -2
- package/src/operations/command.ts +0 -7
- package/src/operations/create_collection.ts +0 -3
- package/src/operations/execute_operation.ts +6 -2
- package/src/operations/find.ts +2 -11
- package/src/read_preference.ts +0 -9
- package/src/sdam/topology.ts +0 -53
- package/src/sessions.ts +1 -1
- package/src/transactions.ts +2 -17
- package/src/utils.ts +0 -18
- package/lib/client-side-encryption/crypto_callbacks.js +0 -81
- package/lib/client-side-encryption/crypto_callbacks.js.map +0 -1
- package/src/client-side-encryption/crypto_callbacks.ts +0 -87
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const MIN_SUPPORTED_SERVER_VERSION = '4.2';
|
|
2
2
|
export const MAX_SUPPORTED_SERVER_VERSION = '8.2';
|
|
3
|
+
export const MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION = 13;
|
|
4
|
+
export const MIN_SUPPORTED_SNAPSHOT_READS_SERVER_VERSION = '5.0';
|
|
3
5
|
export const MIN_SUPPORTED_WIRE_VERSION = 8;
|
|
4
6
|
export const MAX_SUPPORTED_WIRE_VERSION = 27;
|
|
5
7
|
export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;
|
package/src/collection.ts
CHANGED
|
@@ -546,7 +546,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
546
546
|
// Explicitly set the limit to 1 and singleBatch to true for all commands, per the spec.
|
|
547
547
|
// noCursorTimeout must be unset as well as batchSize.
|
|
548
548
|
// See: https://github.com/mongodb/specifications/blob/master/source/crud/crud.md#findone-api-details
|
|
549
|
-
const {
|
|
549
|
+
const { ...opts } = options;
|
|
550
550
|
opts.singleBatch = true;
|
|
551
551
|
const cursor = this.find(filter, opts).limit(1);
|
|
552
552
|
const result = await cursor.next();
|
package/src/connection_string.ts
CHANGED
|
@@ -1283,16 +1283,6 @@ export const OPTIONS = {
|
|
|
1283
1283
|
secureProtocol: { type: 'any' },
|
|
1284
1284
|
index: { type: 'any' },
|
|
1285
1285
|
// Legacy options from v3 era
|
|
1286
|
-
useNewUrlParser: {
|
|
1287
|
-
type: 'boolean',
|
|
1288
|
-
deprecated:
|
|
1289
|
-
'useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
|
|
1290
|
-
} as OptionDescriptor,
|
|
1291
|
-
useUnifiedTopology: {
|
|
1292
|
-
type: 'boolean',
|
|
1293
|
-
deprecated:
|
|
1294
|
-
'useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
|
|
1295
|
-
} as OptionDescriptor,
|
|
1296
1286
|
__skipPingOnConnect: { type: 'boolean' }
|
|
1297
1287
|
} as Record<keyof MongoClientOptions, OptionDescriptor>;
|
|
1298
1288
|
|
package/src/gridfs/download.ts
CHANGED
|
@@ -53,10 +53,6 @@ export interface GridFSFile {
|
|
|
53
53
|
filename: string;
|
|
54
54
|
metadata?: Document;
|
|
55
55
|
uploadDate: Date;
|
|
56
|
-
/** @deprecated Will be removed in the next major version. */
|
|
57
|
-
contentType?: string;
|
|
58
|
-
/** @deprecated Will be removed in the next major version. */
|
|
59
|
-
aliases?: string[];
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
/** @internal */
|
package/src/gridfs/upload.ts
CHANGED
|
@@ -32,16 +32,6 @@ export interface GridFSBucketWriteStreamOptions extends WriteConcernOptions {
|
|
|
32
32
|
id?: ObjectId;
|
|
33
33
|
/** Object to store in the file document's `metadata` field */
|
|
34
34
|
metadata?: Document;
|
|
35
|
-
/**
|
|
36
|
-
* String to store in the file document's `contentType` field.
|
|
37
|
-
* @deprecated Will be removed in the next major version. Add a contentType field to the metadata document instead.
|
|
38
|
-
*/
|
|
39
|
-
contentType?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Array of strings to store in the file document's `aliases` field.
|
|
42
|
-
* @deprecated Will be removed in the next major version. Add an aliases field to the metadata document instead.
|
|
43
|
-
*/
|
|
44
|
-
aliases?: string[];
|
|
45
35
|
/**
|
|
46
36
|
* @experimental
|
|
47
37
|
* Specifies the time an operation will run until it throws a timeout error
|
|
@@ -305,8 +295,6 @@ function checkDone(stream: GridFSBucketWriteStream, callback: Callback): void {
|
|
|
305
295
|
stream.length,
|
|
306
296
|
stream.chunkSizeBytes,
|
|
307
297
|
stream.filename,
|
|
308
|
-
stream.options.contentType,
|
|
309
|
-
stream.options.aliases,
|
|
310
298
|
stream.options.metadata
|
|
311
299
|
);
|
|
312
300
|
|
|
@@ -402,8 +390,6 @@ function createFilesDoc(
|
|
|
402
390
|
length: number,
|
|
403
391
|
chunkSize: number,
|
|
404
392
|
filename: string,
|
|
405
|
-
contentType?: string,
|
|
406
|
-
aliases?: string[],
|
|
407
393
|
metadata?: Document
|
|
408
394
|
): GridFSFile {
|
|
409
395
|
const ret: GridFSFile = {
|
|
@@ -414,14 +400,6 @@ function createFilesDoc(
|
|
|
414
400
|
filename
|
|
415
401
|
};
|
|
416
402
|
|
|
417
|
-
if (contentType) {
|
|
418
|
-
ret.contentType = contentType;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (aliases) {
|
|
422
|
-
ret.aliases = aliases;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
403
|
if (metadata) {
|
|
426
404
|
ret.metadata = metadata;
|
|
427
405
|
}
|
package/src/index.ts
CHANGED
|
@@ -224,7 +224,6 @@ export type {
|
|
|
224
224
|
ChangeStreamSplitEvent,
|
|
225
225
|
ChangeStreamUpdateDocument,
|
|
226
226
|
OperationTime,
|
|
227
|
-
ResumeOptions,
|
|
228
227
|
ResumeToken,
|
|
229
228
|
UpdateDescription
|
|
230
229
|
} from './change_stream';
|
|
@@ -307,7 +306,6 @@ export type {
|
|
|
307
306
|
ProxyOptions
|
|
308
307
|
} from './cmap/connection';
|
|
309
308
|
export type {
|
|
310
|
-
CloseOptions,
|
|
311
309
|
ConnectionPool,
|
|
312
310
|
ConnectionPoolEvents,
|
|
313
311
|
ConnectionPoolOptions,
|
|
@@ -315,7 +313,7 @@ export type {
|
|
|
315
313
|
WaitQueueMember,
|
|
316
314
|
WithConnectionCallback
|
|
317
315
|
} from './cmap/connection_pool';
|
|
318
|
-
export type { ClientMetadata
|
|
316
|
+
export type { ClientMetadata } from './cmap/handshake/client_metadata';
|
|
319
317
|
export type { ConnectionPoolMetrics } from './cmap/metrics';
|
|
320
318
|
export type { StreamDescription, StreamDescriptionOptions } from './cmap/stream_description';
|
|
321
319
|
export type { CompressorName } from './cmap/wire_protocol/compression';
|
|
@@ -598,7 +596,6 @@ export type { SrvPoller, SrvPollerEvents, SrvPollerOptions } from './sdam/srv_po
|
|
|
598
596
|
export type {
|
|
599
597
|
ConnectOptions,
|
|
600
598
|
SelectServerOptions,
|
|
601
|
-
ServerCapabilities,
|
|
602
599
|
ServerSelectionCallback,
|
|
603
600
|
ServerSelectionRequest,
|
|
604
601
|
Topology,
|
package/src/mongo_types.ts
CHANGED
|
@@ -473,8 +473,7 @@ export class TypedEventEmitter<Events extends EventsDescription> extends EventEm
|
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
/**
|
|
476
|
-
* @
|
|
477
|
-
* @deprecated Will be removed in favor of `AbortSignal` in the next major release.
|
|
476
|
+
* @internal
|
|
478
477
|
*/
|
|
479
478
|
export class CancellationToken extends TypedEventEmitter<{ cancel(): void }> {
|
|
480
479
|
constructor(...args: any[]) {
|
|
@@ -53,13 +53,6 @@ export interface CommandOperationOptions
|
|
|
53
53
|
* In server versions 4.4 and above, 'comment' can be any valid BSON type.
|
|
54
54
|
*/
|
|
55
55
|
comment?: unknown;
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated
|
|
58
|
-
* This option is deprecated and will be removed in a future release as it is not used
|
|
59
|
-
* in the driver. Use MongoClientOptions or connection string parameters instead.
|
|
60
|
-
* */
|
|
61
|
-
retryWrites?: boolean;
|
|
62
|
-
|
|
63
56
|
// Admin command overrides.
|
|
64
57
|
dbName?: string;
|
|
65
58
|
authdb?: string;
|
|
@@ -23,7 +23,6 @@ const ILLEGAL_COMMAND_FIELDS = new Set([
|
|
|
23
23
|
'timeoutMS',
|
|
24
24
|
'j',
|
|
25
25
|
'fsync',
|
|
26
|
-
'autoIndexId',
|
|
27
26
|
'pkFactory',
|
|
28
27
|
'raw',
|
|
29
28
|
'readPreference',
|
|
@@ -68,8 +67,6 @@ export interface ClusteredCollectionOptions extends Document {
|
|
|
68
67
|
export interface CreateCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
69
68
|
/** Create a capped collection */
|
|
70
69
|
capped?: boolean;
|
|
71
|
-
/** @deprecated Create an index on the _id field of the document. This option is deprecated in MongoDB 3.2+ and will be removed once no longer supported by the server. */
|
|
72
|
-
autoIndexId?: boolean;
|
|
73
70
|
/** The size of the capped collection in bytes */
|
|
74
71
|
size?: number;
|
|
75
72
|
/** The maximum number of documents in the capped collection */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION } from '../cmap/wire_protocol/constants';
|
|
1
2
|
import {
|
|
2
3
|
isRetryableReadError,
|
|
3
4
|
isRetryableWriteError,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
import type { Topology } from '../sdam/topology';
|
|
26
27
|
import type { ClientSession } from '../sessions';
|
|
27
28
|
import { TimeoutContext } from '../timeout';
|
|
28
|
-
import { abortable, supportsRetryableWrites } from '../utils';
|
|
29
|
+
import { abortable, maxWireVersion, supportsRetryableWrites } from '../utils';
|
|
29
30
|
import { AggregateOperation } from './aggregate';
|
|
30
31
|
import { AbstractOperation, Aspect } from './operation';
|
|
31
32
|
|
|
@@ -81,7 +82,10 @@ export async function executeOperation<
|
|
|
81
82
|
session = client.startSession({ owner, explicit: false });
|
|
82
83
|
} else if (session.hasEnded) {
|
|
83
84
|
throw new MongoExpiredSessionError('Use of expired sessions is not permitted');
|
|
84
|
-
} else if (
|
|
85
|
+
} else if (
|
|
86
|
+
session.snapshotEnabled &&
|
|
87
|
+
maxWireVersion(topology) < MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION
|
|
88
|
+
) {
|
|
85
89
|
throw new MongoCompatibilityError('Snapshot reads require MongoDB 5.0 or later');
|
|
86
90
|
} else if (session.client !== client) {
|
|
87
91
|
throw new MongoInvalidArgumentError('ClientSession must be from the same MongoClient');
|
package/src/operations/find.ts
CHANGED
|
@@ -12,10 +12,8 @@ import { Aspect, defineAspects, type Hint } from './operation';
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
15
|
-
* @typeParam TSchema - Unused schema definition, deprecated usage, only specify `FindOptions` with no generic
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
export interface FindOptions<TSchema extends Document = Document>
|
|
16
|
+
export interface FindOptions
|
|
19
17
|
extends Omit<CommandOperationOptions, 'writeConcern' | 'explain'>,
|
|
20
18
|
AbstractCursorOptions {
|
|
21
19
|
/** Sets the limit of documents returned in the query. */
|
|
@@ -76,14 +74,7 @@ export interface FindOptions<TSchema extends Document = Document>
|
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
/** @public */
|
|
79
|
-
export
|
|
80
|
-
/** @deprecated Will be removed in the next major version. User provided value will be ignored. */
|
|
81
|
-
batchSize?: number;
|
|
82
|
-
/** @deprecated Will be removed in the next major version. User provided value will be ignored. */
|
|
83
|
-
limit?: number;
|
|
84
|
-
/** @deprecated Will be removed in the next major version. User provided value will be ignored. */
|
|
85
|
-
noCursorTimeout?: boolean;
|
|
86
|
-
}
|
|
77
|
+
export type FindOneOptions = Omit<FindOptions, 'batchSize' | 'limit' | 'noCursorTimeout'>;
|
|
87
78
|
|
|
88
79
|
/** @internal */
|
|
89
80
|
export class FindOperation extends CommandOperation<CursorResponse> {
|
package/src/read_preference.ts
CHANGED
|
@@ -63,10 +63,6 @@ export class ReadPreference {
|
|
|
63
63
|
tags?: TagSet[];
|
|
64
64
|
hedge?: HedgeOptions;
|
|
65
65
|
maxStalenessSeconds?: number;
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated This will be removed as dead code in the next major version.
|
|
68
|
-
*/
|
|
69
|
-
minWireVersion?: number;
|
|
70
66
|
|
|
71
67
|
public static PRIMARY = ReadPreferenceMode.primary;
|
|
72
68
|
public static PRIMARY_PREFERRED = ReadPreferenceMode.primaryPreferred;
|
|
@@ -100,7 +96,6 @@ export class ReadPreference {
|
|
|
100
96
|
this.tags = tags;
|
|
101
97
|
this.hedge = options?.hedge;
|
|
102
98
|
this.maxStalenessSeconds = undefined;
|
|
103
|
-
this.minWireVersion = undefined;
|
|
104
99
|
|
|
105
100
|
options = options ?? {};
|
|
106
101
|
if (options.maxStalenessSeconds != null) {
|
|
@@ -109,10 +104,6 @@ export class ReadPreference {
|
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
this.maxStalenessSeconds = options.maxStalenessSeconds;
|
|
112
|
-
|
|
113
|
-
// NOTE: The minimum required wire version is 5 for this read preference. If the existing
|
|
114
|
-
// topology has a lower value then a MongoError will be thrown during server selection.
|
|
115
|
-
this.minWireVersion = 5;
|
|
116
107
|
}
|
|
117
108
|
|
|
118
109
|
if (this.mode === ReadPreference.PRIMARY) {
|
package/src/sdam/topology.ts
CHANGED
|
@@ -393,10 +393,6 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
|
|
|
393
393
|
return this.s.options.serverApi;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
-
get capabilities(): ServerCapabilities {
|
|
397
|
-
return new ServerCapabilities(this.lastHello());
|
|
398
|
-
}
|
|
399
|
-
|
|
400
396
|
/** Initiate server connect */
|
|
401
397
|
async connect(options?: ConnectOptions): Promise<Topology> {
|
|
402
398
|
this.connectionLock ??= this._connect(options);
|
|
@@ -1103,52 +1099,3 @@ function isStaleServerDescription(
|
|
|
1103
1099
|
compareTopologyVersion(currentTopologyVersion, incomingServerDescription.topologyVersion) > 0
|
|
1104
1100
|
);
|
|
1105
1101
|
}
|
|
1106
|
-
|
|
1107
|
-
/**
|
|
1108
|
-
* @public
|
|
1109
|
-
* @deprecated This class will be removed as dead code in the next major version.
|
|
1110
|
-
*/
|
|
1111
|
-
export class ServerCapabilities {
|
|
1112
|
-
maxWireVersion: number;
|
|
1113
|
-
minWireVersion: number;
|
|
1114
|
-
|
|
1115
|
-
constructor(hello: Document) {
|
|
1116
|
-
this.minWireVersion = hello.minWireVersion || 0;
|
|
1117
|
-
this.maxWireVersion = hello.maxWireVersion || 0;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
get hasAggregationCursor(): boolean {
|
|
1121
|
-
return true;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
get hasWriteCommands(): boolean {
|
|
1125
|
-
return true;
|
|
1126
|
-
}
|
|
1127
|
-
get hasTextSearch(): boolean {
|
|
1128
|
-
return true;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
get hasAuthCommands(): boolean {
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
get hasListCollectionsCommand(): boolean {
|
|
1136
|
-
return true;
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
get hasListIndexesCommand(): boolean {
|
|
1140
|
-
return true;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
get supportsSnapshotReads(): boolean {
|
|
1144
|
-
return this.maxWireVersion >= 13;
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
get commandsTakeWriteConcern(): boolean {
|
|
1148
|
-
return true;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
get commandsTakeCollation(): boolean {
|
|
1152
|
-
return true;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
package/src/sessions.ts
CHANGED
|
@@ -118,7 +118,7 @@ export class ClientSession
|
|
|
118
118
|
/** @internal */
|
|
119
119
|
owner?: symbol | AbstractCursor;
|
|
120
120
|
defaultTransactionOptions: TransactionOptions;
|
|
121
|
-
/** @
|
|
121
|
+
/** @internal */
|
|
122
122
|
transaction: Transaction;
|
|
123
123
|
/**
|
|
124
124
|
* @internal
|
package/src/transactions.ts
CHANGED
|
@@ -73,21 +73,15 @@ export interface TransactionOptions extends Omit<CommandOperationOptions, 'timeo
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* @
|
|
77
|
-
* @deprecated - Will be made internal in a future major release.
|
|
78
|
-
* A class maintaining state related to a server transaction. Internal Only
|
|
76
|
+
* @internal
|
|
79
77
|
*/
|
|
80
78
|
export class Transaction {
|
|
81
|
-
/** @internal */
|
|
82
79
|
state: TxnState;
|
|
83
|
-
/** @deprecated - Will be made internal in a future major release. */
|
|
84
80
|
options: TransactionOptions;
|
|
85
|
-
/** @internal */
|
|
86
81
|
_pinnedServer?: Server;
|
|
87
|
-
/** @internal */
|
|
88
82
|
_recoveryToken?: Document;
|
|
89
83
|
|
|
90
|
-
/** Create a transaction
|
|
84
|
+
/** Create a transaction */
|
|
91
85
|
constructor(options?: TransactionOptions) {
|
|
92
86
|
options = options ?? {};
|
|
93
87
|
this.state = TxnState.NO_TRANSACTION;
|
|
@@ -119,23 +113,19 @@ export class Transaction {
|
|
|
119
113
|
this._recoveryToken = undefined;
|
|
120
114
|
}
|
|
121
115
|
|
|
122
|
-
/** @internal */
|
|
123
116
|
get server(): Server | undefined {
|
|
124
117
|
return this._pinnedServer;
|
|
125
118
|
}
|
|
126
119
|
|
|
127
|
-
/** @deprecated - Will be made internal in a future major release. */
|
|
128
120
|
get recoveryToken(): Document | undefined {
|
|
129
121
|
return this._recoveryToken;
|
|
130
122
|
}
|
|
131
123
|
|
|
132
|
-
/** @deprecated - Will be made internal in a future major release. */
|
|
133
124
|
get isPinned(): boolean {
|
|
134
125
|
return !!this.server;
|
|
135
126
|
}
|
|
136
127
|
|
|
137
128
|
/**
|
|
138
|
-
* @deprecated - Will be made internal in a future major release.
|
|
139
129
|
* @returns Whether the transaction has started
|
|
140
130
|
*/
|
|
141
131
|
get isStarting(): boolean {
|
|
@@ -143,20 +133,17 @@ export class Transaction {
|
|
|
143
133
|
}
|
|
144
134
|
|
|
145
135
|
/**
|
|
146
|
-
* @deprecated - Will be made internal in a future major release.
|
|
147
136
|
* @returns Whether this session is presently in a transaction
|
|
148
137
|
*/
|
|
149
138
|
get isActive(): boolean {
|
|
150
139
|
return ACTIVE_STATES.has(this.state);
|
|
151
140
|
}
|
|
152
141
|
|
|
153
|
-
/** @deprecated - Will be made internal in a future major release. */
|
|
154
142
|
get isCommitted(): boolean {
|
|
155
143
|
return COMMITTED_STATES.has(this.state);
|
|
156
144
|
}
|
|
157
145
|
/**
|
|
158
146
|
* Transition the transaction in the state machine
|
|
159
|
-
* @internal
|
|
160
147
|
* @param nextState - The new state to transition to
|
|
161
148
|
*/
|
|
162
149
|
transition(nextState: TxnState): void {
|
|
@@ -178,14 +165,12 @@ export class Transaction {
|
|
|
178
165
|
);
|
|
179
166
|
}
|
|
180
167
|
|
|
181
|
-
/** @internal */
|
|
182
168
|
pinServer(server: Server): void {
|
|
183
169
|
if (this.isActive) {
|
|
184
170
|
this._pinnedServer = server;
|
|
185
171
|
}
|
|
186
172
|
}
|
|
187
173
|
|
|
188
|
-
/** @internal */
|
|
189
174
|
unpinServer(): void {
|
|
190
175
|
this._pinnedServer = undefined;
|
|
191
176
|
}
|
package/src/utils.ts
CHANGED
|
@@ -153,24 +153,6 @@ export function filterOptions(options: AnyOptions, names: ReadonlyArray<string>)
|
|
|
153
153
|
return filterOptions;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
interface HasRetryableWrites {
|
|
157
|
-
retryWrites?: boolean;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Applies retryWrites: true to a command if retryWrites is set on the command's database.
|
|
161
|
-
* @internal
|
|
162
|
-
*
|
|
163
|
-
* @param target - The target command to which we will apply retryWrites.
|
|
164
|
-
* @param db - The database from which we can inherit a retryWrites value.
|
|
165
|
-
*/
|
|
166
|
-
export function applyRetryableWrites<T extends HasRetryableWrites>(target: T, db?: Db): T {
|
|
167
|
-
if (db && db.s.options?.retryWrites) {
|
|
168
|
-
target.retryWrites = true;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return target;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
156
|
/**
|
|
175
157
|
* Applies a write concern to a command based on well defined inheritance rules, optionally
|
|
176
158
|
* detecting support for the write concern in the first place.
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hmacSha256Hook = exports.hmacSha512Hook = exports.aes256CtrDecryptHook = exports.aes256CtrEncryptHook = exports.aes256CbcDecryptHook = exports.aes256CbcEncryptHook = void 0;
|
|
4
|
-
exports.makeAES256Hook = makeAES256Hook;
|
|
5
|
-
exports.randomHook = randomHook;
|
|
6
|
-
exports.sha256Hook = sha256Hook;
|
|
7
|
-
exports.makeHmacHook = makeHmacHook;
|
|
8
|
-
exports.signRsaSha256Hook = signRsaSha256Hook;
|
|
9
|
-
const crypto = require("crypto");
|
|
10
|
-
function makeAES256Hook(method, mode) {
|
|
11
|
-
return function (key, iv, input, output) {
|
|
12
|
-
let result;
|
|
13
|
-
try {
|
|
14
|
-
const cipher = crypto[method](mode, key, iv);
|
|
15
|
-
cipher.setAutoPadding(false);
|
|
16
|
-
result = cipher.update(input);
|
|
17
|
-
const final = cipher.final();
|
|
18
|
-
if (final.length > 0) {
|
|
19
|
-
result = Buffer.concat([result, final]);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
result.copy(output);
|
|
26
|
-
return result.length;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function randomHook(buffer, count) {
|
|
30
|
-
try {
|
|
31
|
-
crypto.randomFillSync(buffer, 0, count);
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
return e;
|
|
35
|
-
}
|
|
36
|
-
return count;
|
|
37
|
-
}
|
|
38
|
-
function sha256Hook(input, output) {
|
|
39
|
-
let result;
|
|
40
|
-
try {
|
|
41
|
-
result = crypto.createHash('sha256').update(input).digest();
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
return e;
|
|
45
|
-
}
|
|
46
|
-
result.copy(output);
|
|
47
|
-
return result.length;
|
|
48
|
-
}
|
|
49
|
-
function makeHmacHook(algorithm) {
|
|
50
|
-
return (key, input, output) => {
|
|
51
|
-
let result;
|
|
52
|
-
try {
|
|
53
|
-
result = crypto.createHmac(algorithm, key).update(input).digest();
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
return e;
|
|
57
|
-
}
|
|
58
|
-
result.copy(output);
|
|
59
|
-
return result.length;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function signRsaSha256Hook(key, input, output) {
|
|
63
|
-
let result;
|
|
64
|
-
try {
|
|
65
|
-
const signer = crypto.createSign('sha256WithRSAEncryption');
|
|
66
|
-
const privateKey = Buffer.from(`-----BEGIN PRIVATE KEY-----\n${key.toString('base64')}\n-----END PRIVATE KEY-----\n`);
|
|
67
|
-
result = signer.update(input).end().sign(privateKey);
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
return e;
|
|
71
|
-
}
|
|
72
|
-
result.copy(output);
|
|
73
|
-
return result.length;
|
|
74
|
-
}
|
|
75
|
-
exports.aes256CbcEncryptHook = makeAES256Hook('createCipheriv', 'aes-256-cbc');
|
|
76
|
-
exports.aes256CbcDecryptHook = makeAES256Hook('createDecipheriv', 'aes-256-cbc');
|
|
77
|
-
exports.aes256CtrEncryptHook = makeAES256Hook('createCipheriv', 'aes-256-ctr');
|
|
78
|
-
exports.aes256CtrDecryptHook = makeAES256Hook('createDecipheriv', 'aes-256-ctr');
|
|
79
|
-
exports.hmacSha512Hook = makeHmacHook('sha512');
|
|
80
|
-
exports.hmacSha256Hook = makeHmacHook('sha256');
|
|
81
|
-
//# sourceMappingURL=crypto_callbacks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto_callbacks.js","sourceRoot":"","sources":["../../src/client-side-encryption/crypto_callbacks.ts"],"names":[],"mappings":";;;AAIA,wCAsBC;AAED,gCAOC;AAED,gCAUC;AAGD,oCAYC;AAED,8CAeC;AA/ED,iCAAiC;AAIjC,SAAgB,cAAc,CAC5B,MAA6C,EAC7C,IAAmC;IAEnC,OAAO,UAAU,GAAW,EAAE,EAAU,EAAE,KAAa,EAAE,MAAc;QACrE,IAAI,MAAM,CAAC;QAEX,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAC7C,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC7B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAa;IACtD,IAAI,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,UAAU,CAAC,KAAa,EAAE,MAAc;IACtD,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAGD,SAAgB,YAAY,CAAC,SAA8B;IACzD,OAAO,CAAC,GAAW,EAAE,KAAa,EAAE,MAAc,EAAkB,EAAE;QACpE,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACpE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAAC,GAAW,EAAE,KAAa,EAAE,MAAc;IAC1E,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAC5B,gCAAgC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,+BAA+B,CACtF,CAAC;QAEF,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAEY,QAAA,oBAAoB,GAAG,cAAc,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AACvE,QAAA,oBAAoB,GAAG,cAAc,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AACzE,QAAA,oBAAoB,GAAG,cAAc,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AACvE,QAAA,oBAAoB,GAAG,cAAc,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AACzE,QAAA,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AACxC,QAAA,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
type AES256Callback = (key: Buffer, iv: Buffer, input: Buffer, output: Buffer) => number | Error;
|
|
4
|
-
|
|
5
|
-
export function makeAES256Hook(
|
|
6
|
-
method: 'createCipheriv' | 'createDecipheriv',
|
|
7
|
-
mode: 'aes-256-cbc' | 'aes-256-ctr'
|
|
8
|
-
): AES256Callback {
|
|
9
|
-
return function (key: Buffer, iv: Buffer, input: Buffer, output: Buffer): number | Error {
|
|
10
|
-
let result;
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const cipher = crypto[method](mode, key, iv);
|
|
14
|
-
cipher.setAutoPadding(false);
|
|
15
|
-
result = cipher.update(input);
|
|
16
|
-
const final = cipher.final();
|
|
17
|
-
if (final.length > 0) {
|
|
18
|
-
result = Buffer.concat([result, final]);
|
|
19
|
-
}
|
|
20
|
-
} catch (e) {
|
|
21
|
-
return e;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
result.copy(output);
|
|
25
|
-
return result.length;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function randomHook(buffer: Buffer, count: number): number | Error {
|
|
30
|
-
try {
|
|
31
|
-
crypto.randomFillSync(buffer, 0, count);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
return e;
|
|
34
|
-
}
|
|
35
|
-
return count;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function sha256Hook(input: Buffer, output: Buffer): number | Error {
|
|
39
|
-
let result;
|
|
40
|
-
try {
|
|
41
|
-
result = crypto.createHash('sha256').update(input).digest();
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return e;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
result.copy(output);
|
|
47
|
-
return result.length;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type HMACHook = (key: Buffer, input: Buffer, output: Buffer) => number | Error;
|
|
51
|
-
export function makeHmacHook(algorithm: 'sha512' | 'sha256'): HMACHook {
|
|
52
|
-
return (key: Buffer, input: Buffer, output: Buffer): number | Error => {
|
|
53
|
-
let result;
|
|
54
|
-
try {
|
|
55
|
-
result = crypto.createHmac(algorithm, key).update(input).digest();
|
|
56
|
-
} catch (e) {
|
|
57
|
-
return e;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
result.copy(output);
|
|
61
|
-
return result.length;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function signRsaSha256Hook(key: Buffer, input: Buffer, output: Buffer): number | Error {
|
|
66
|
-
let result;
|
|
67
|
-
try {
|
|
68
|
-
const signer = crypto.createSign('sha256WithRSAEncryption');
|
|
69
|
-
const privateKey = Buffer.from(
|
|
70
|
-
`-----BEGIN PRIVATE KEY-----\n${key.toString('base64')}\n-----END PRIVATE KEY-----\n`
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
result = signer.update(input).end().sign(privateKey);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
return e;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
result.copy(output);
|
|
79
|
-
return result.length;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const aes256CbcEncryptHook = makeAES256Hook('createCipheriv', 'aes-256-cbc');
|
|
83
|
-
export const aes256CbcDecryptHook = makeAES256Hook('createDecipheriv', 'aes-256-cbc');
|
|
84
|
-
export const aes256CtrEncryptHook = makeAES256Hook('createCipheriv', 'aes-256-ctr');
|
|
85
|
-
export const aes256CtrDecryptHook = makeAES256Hook('createDecipheriv', 'aes-256-ctr');
|
|
86
|
-
export const hmacSha512Hook = makeHmacHook('sha512');
|
|
87
|
-
export const hmacSha256Hook = makeHmacHook('sha256');
|