mongodb 6.20.0 → 7.0.0-dev.20251107.sha.5db818c2
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/README.md +17 -18
- package/lib/bulk/common.js +7 -9
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +84 -38
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +2 -4
- 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/client-side-encryption/mongocryptd_manager.js +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js +10 -58
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +0 -15
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +2 -7
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/providers.js +0 -1
- package/lib/cmap/auth/providers.js.map +1 -1
- package/lib/cmap/connect.js +1 -1
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +28 -27
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +59 -59
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/errors.js +1 -1
- package/lib/cmap/errors.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +7 -5
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/metrics.js +3 -3
- package/lib/cmap/metrics.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/cmap/wire_protocol/on_data.js +0 -1
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +2 -2
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/collection.js +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +8 -10
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +17 -34
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js +2 -2
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +37 -26
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js +1 -1
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/db.js +6 -6
- package/lib/db.js.map +1 -1
- package/lib/error.js +2 -2
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +5 -5
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +9 -9
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +2 -8
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +58 -67
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js +0 -6
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +1 -2
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +0 -3
- package/lib/operations/aggregate.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/drop.js +8 -9
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/end_sessions.js +34 -0
- package/lib/operations/end_sessions.js.map +1 -0
- 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 +10 -14
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/server.js +14 -14
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/srv_polling.js +2 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +24 -68
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +5 -4
- package/lib/sessions.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 +72 -239
- package/package.json +17 -20
- package/src/bulk/common.ts +9 -11
- package/src/change_stream.ts +85 -37
- package/src/client-side-encryption/auto_encrypter.ts +6 -12
- package/src/client-side-encryption/client_encryption.ts +5 -6
- package/src/client-side-encryption/errors.ts +3 -0
- package/src/cmap/auth/aws_temporary_credentials.ts +12 -70
- package/src/cmap/auth/mongo_credentials.ts +1 -20
- package/src/cmap/auth/mongodb_aws.ts +8 -17
- package/src/cmap/auth/providers.ts +0 -1
- package/src/cmap/connect.ts +1 -1
- package/src/cmap/connection.ts +14 -16
- package/src/cmap/connection_pool.ts +4 -13
- package/src/cmap/errors.ts +1 -1
- package/src/cmap/handshake/client_metadata.ts +18 -26
- package/src/cmap/wire_protocol/constants.ts +2 -0
- package/src/cmap/wire_protocol/on_data.ts +1 -2
- package/src/collection.ts +1 -1
- package/src/connection_string.ts +13 -20
- package/src/cursor/abstract_cursor.ts +12 -49
- package/src/cursor/change_stream_cursor.ts +2 -2
- package/src/cursor/find_cursor.ts +40 -27
- package/src/cursor/run_command_cursor.ts +1 -1
- package/src/error.ts +2 -2
- package/src/gridfs/download.ts +0 -4
- package/src/gridfs/upload.ts +0 -22
- package/src/index.ts +2 -8
- package/src/mongo_client.ts +68 -100
- package/src/mongo_client_auth_providers.ts +0 -8
- package/src/mongo_logger.ts +1 -1
- package/src/mongo_types.ts +1 -2
- package/src/operations/aggregate.ts +0 -6
- package/src/operations/command.ts +0 -12
- package/src/operations/create_collection.ts +0 -3
- package/src/operations/drop.ts +9 -11
- package/src/operations/end_sessions.ts +44 -0
- 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 +2 -60
- package/src/sessions.ts +2 -8
- package/src/transactions.ts +2 -17
- package/src/utils.ts +0 -18
- package/tsconfig.json +5 -7
- package/lib/beta.d.ts +0 -9224
- package/lib/beta.js +0 -21
- package/lib/beta.js.map +0 -1
- package/lib/client-side-encryption/crypto_callbacks.js +0 -81
- package/lib/client-side-encryption/crypto_callbacks.js.map +0 -1
- package/lib/resource_management.js +0 -58
- package/lib/resource_management.js.map +0 -1
- package/src/beta.ts +0 -22
- package/src/client-side-encryption/crypto_callbacks.ts +0 -87
- package/src/resource_management.ts +0 -74
package/lib/beta.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
__exportStar(require("./index"), exports);
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*
|
|
7
|
-
* Since we don't bundle tslib helpers, we need to polyfill this method.
|
|
8
|
-
*
|
|
9
|
-
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
|
|
10
|
-
*/
|
|
11
|
-
function __exportStar(mod) {
|
|
12
|
-
for (const key of Object.keys(mod)) {
|
|
13
|
-
Object.defineProperty(exports, key, {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return mod[key];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=beta.js.map
|
package/lib/beta.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../src/beta.ts"],"names":[],"mappings":";;AAEA,0CAAwB;AAExB;;;;;;GAMG;AAEH,SAAS,YAAY,CAAC,GAAa;IACjC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE;gBACH,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -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":"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"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureResourceManagement = configureResourceManagement;
|
|
4
|
-
exports.configureExplicitResourceManagement = configureExplicitResourceManagement;
|
|
5
|
-
/** @internal */
|
|
6
|
-
function configureResourceManagement(target) {
|
|
7
|
-
Symbol.asyncDispose &&
|
|
8
|
-
Object.defineProperty(target, Symbol.asyncDispose, {
|
|
9
|
-
value: async function asyncDispose() {
|
|
10
|
-
await this.asyncDispose();
|
|
11
|
-
},
|
|
12
|
-
enumerable: false,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @beta
|
|
19
|
-
* @experimental
|
|
20
|
-
*
|
|
21
|
-
* Attaches `Symbol.asyncDispose` methods to the MongoClient, Cursors, sessions and change streams
|
|
22
|
-
* if Symbol.asyncDispose is defined.
|
|
23
|
-
*
|
|
24
|
-
* It's usually not necessary to call this method - the driver attempts to attach these methods
|
|
25
|
-
* itself when its loaded. However, sometimes the driver may be loaded before `Symbol.asyncDispose`
|
|
26
|
-
* is defined, in which case it is necessary to call this method directly. This can happen if the
|
|
27
|
-
* application is polyfilling `Symbol.asyncDispose`.
|
|
28
|
-
*
|
|
29
|
-
* Example:
|
|
30
|
-
*
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { configureExplicitResourceManagement, MongoClient } from 'mongodb/lib/beta';
|
|
33
|
-
*
|
|
34
|
-
* Symbol.asyncDispose ??= Symbol('dispose');
|
|
35
|
-
* load();
|
|
36
|
-
*
|
|
37
|
-
* await using client = new MongoClient(...);
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
function configureExplicitResourceManagement() {
|
|
41
|
-
// We must import lazily here, because there's a circular dependency between the resource management
|
|
42
|
-
// file and each resources' file. We could move `configureResourceManagement` to a separate
|
|
43
|
-
// function, but keeping all resource-management related code together seemed preferable and I chose
|
|
44
|
-
// lazy requiring of resources instead.
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
|
-
const { MongoClient } = require('./mongo_client');
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
48
|
-
const { ClientSession } = require('./sessions');
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
50
|
-
const { AbstractCursor } = require('./cursor/abstract_cursor');
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
52
|
-
const { ChangeStream } = require('./change_stream');
|
|
53
|
-
configureResourceManagement(MongoClient.prototype);
|
|
54
|
-
configureResourceManagement(ClientSession.prototype);
|
|
55
|
-
configureResourceManagement(AbstractCursor.prototype);
|
|
56
|
-
configureResourceManagement(ChangeStream.prototype);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=resource_management.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource_management.js","sourceRoot":"","sources":["../src/resource_management.ts"],"names":[],"mappings":";;AAmBA,kEAUC;AAyBD,kFAmBC;AAvDD,gBAAgB;AAChB,SAAgB,2BAA2B,CAAC,MAAuB;IACjE,MAAM,CAAC,YAAY;QACjB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE;YACjD,KAAK,EAAE,KAAK,UAAU,YAAY;gBAChC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5B,CAAC;YACD,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,mCAAmC;IACjD,oGAAoG;IACpG,4FAA4F;IAC5F,oGAAoG;IACpG,uCAAuC;IAEvC,iEAAiE;IACjE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAClD,iEAAiE;IACjE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAChD,iEAAiE;IACjE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC/D,iEAAiE;IACjE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEpD,2BAA2B,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACnD,2BAA2B,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACrD,2BAA2B,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACtD,2BAA2B,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC"}
|
package/src/beta.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type Document } from './bson';
|
|
2
|
-
|
|
3
|
-
export * from './index';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*
|
|
8
|
-
* Since we don't bundle tslib helpers, we need to polyfill this method.
|
|
9
|
-
*
|
|
10
|
-
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
function __exportStar(mod: Document) {
|
|
14
|
-
for (const key of Object.keys(mod)) {
|
|
15
|
-
Object.defineProperty(exports, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return mod[key];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -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');
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export interface AsyncDisposable {
|
|
5
|
-
/**
|
|
6
|
-
* @beta
|
|
7
|
-
* @experimental
|
|
8
|
-
*/
|
|
9
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*
|
|
14
|
-
* A method that wraps disposal semantics for a given resource in the class.
|
|
15
|
-
*/
|
|
16
|
-
asyncDispose(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @internal */
|
|
20
|
-
export function configureResourceManagement(target: AsyncDisposable) {
|
|
21
|
-
Symbol.asyncDispose &&
|
|
22
|
-
Object.defineProperty(target, Symbol.asyncDispose, {
|
|
23
|
-
value: async function asyncDispose(this: AsyncDisposable) {
|
|
24
|
-
await this.asyncDispose();
|
|
25
|
-
},
|
|
26
|
-
enumerable: false,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @beta
|
|
34
|
-
* @experimental
|
|
35
|
-
*
|
|
36
|
-
* Attaches `Symbol.asyncDispose` methods to the MongoClient, Cursors, sessions and change streams
|
|
37
|
-
* if Symbol.asyncDispose is defined.
|
|
38
|
-
*
|
|
39
|
-
* It's usually not necessary to call this method - the driver attempts to attach these methods
|
|
40
|
-
* itself when its loaded. However, sometimes the driver may be loaded before `Symbol.asyncDispose`
|
|
41
|
-
* is defined, in which case it is necessary to call this method directly. This can happen if the
|
|
42
|
-
* application is polyfilling `Symbol.asyncDispose`.
|
|
43
|
-
*
|
|
44
|
-
* Example:
|
|
45
|
-
*
|
|
46
|
-
* ```typescript
|
|
47
|
-
* import { configureExplicitResourceManagement, MongoClient } from 'mongodb/lib/beta';
|
|
48
|
-
*
|
|
49
|
-
* Symbol.asyncDispose ??= Symbol('dispose');
|
|
50
|
-
* load();
|
|
51
|
-
*
|
|
52
|
-
* await using client = new MongoClient(...);
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export function configureExplicitResourceManagement() {
|
|
56
|
-
// We must import lazily here, because there's a circular dependency between the resource management
|
|
57
|
-
// file and each resources' file. We could move `configureResourceManagement` to a separate
|
|
58
|
-
// function, but keeping all resource-management related code together seemed preferable and I chose
|
|
59
|
-
// lazy requiring of resources instead.
|
|
60
|
-
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62
|
-
const { MongoClient } = require('./mongo_client');
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
64
|
-
const { ClientSession } = require('./sessions');
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
66
|
-
const { AbstractCursor } = require('./cursor/abstract_cursor');
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
68
|
-
const { ChangeStream } = require('./change_stream');
|
|
69
|
-
|
|
70
|
-
configureResourceManagement(MongoClient.prototype);
|
|
71
|
-
configureResourceManagement(ClientSession.prototype);
|
|
72
|
-
configureResourceManagement(AbstractCursor.prototype);
|
|
73
|
-
configureResourceManagement(ChangeStream.prototype);
|
|
74
|
-
}
|