mongodb 3.6.11 → 3.6.12
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/core/auth/mongo_credentials.js +4 -1
- package/lib/core/auth/mongodb_aws.js +16 -15
- package/lib/core/connection/connection.js +1 -0
- package/lib/core/connection/pool.js +1 -0
- package/lib/core/connection/utils.js +35 -2
- package/lib/core/sdam/topology.js +4 -1
- package/lib/db.js +1 -0
- package/lib/utils.js +10 -1
- package/package.json +1 -1
- package/HISTORY.md +0 -2908
|
@@ -58,7 +58,10 @@ class MongoCredentials {
|
|
|
58
58
|
this.password = process.env.AWS_SECRET_ACCESS_KEY;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (
|
|
61
|
+
if (
|
|
62
|
+
this.mechanismProperties.AWS_SESSION_TOKEN == null &&
|
|
63
|
+
process.env.AWS_SESSION_TOKEN != null
|
|
64
|
+
) {
|
|
62
65
|
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
|
|
63
66
|
}
|
|
64
67
|
}
|
|
@@ -51,12 +51,21 @@ class MongoDBAWS extends AuthProvider {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const username = credentials.username;
|
|
55
|
-
const password = credentials.password;
|
|
56
54
|
const db = credentials.source;
|
|
57
|
-
const token = credentials.mechanismProperties.AWS_SESSION_TOKEN;
|
|
58
55
|
const bson = this.bson;
|
|
59
56
|
|
|
57
|
+
const accessKeyId = credentials.username;
|
|
58
|
+
const secretAccessKey = credentials.password;
|
|
59
|
+
const sessionToken = credentials.mechanismProperties.AWS_SESSION_TOKEN;
|
|
60
|
+
|
|
61
|
+
// If all three defined, include sessionToken, else include username and pass, else no credentials
|
|
62
|
+
const awsCredentials =
|
|
63
|
+
accessKeyId && secretAccessKey && sessionToken
|
|
64
|
+
? { accessKeyId, secretAccessKey, sessionToken }
|
|
65
|
+
: accessKeyId && secretAccessKey
|
|
66
|
+
? { accessKeyId, secretAccessKey }
|
|
67
|
+
: undefined;
|
|
68
|
+
|
|
60
69
|
crypto.randomBytes(32, (err, nonce) => {
|
|
61
70
|
if (err) {
|
|
62
71
|
callback(err);
|
|
@@ -109,18 +118,14 @@ class MongoDBAWS extends AuthProvider {
|
|
|
109
118
|
path: '/',
|
|
110
119
|
body
|
|
111
120
|
},
|
|
112
|
-
|
|
113
|
-
accessKeyId: username,
|
|
114
|
-
secretAccessKey: password,
|
|
115
|
-
token
|
|
116
|
-
}
|
|
121
|
+
awsCredentials
|
|
117
122
|
);
|
|
118
123
|
|
|
119
124
|
const authorization = options.headers.Authorization;
|
|
120
125
|
const date = options.headers['X-Amz-Date'];
|
|
121
126
|
const payload = { a: authorization, d: date };
|
|
122
|
-
if (
|
|
123
|
-
payload.t =
|
|
127
|
+
if (sessionToken) {
|
|
128
|
+
payload.t = sessionToken;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
const saslContinue = {
|
|
@@ -164,6 +169,7 @@ function makeTempCredentials(credentials, callback) {
|
|
|
164
169
|
if (process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
|
|
165
170
|
request(
|
|
166
171
|
`${AWS_RELATIVE_URI}${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`,
|
|
172
|
+
undefined,
|
|
167
173
|
(err, res) => {
|
|
168
174
|
if (err) return callback(err);
|
|
169
175
|
done(res);
|
|
@@ -215,11 +221,6 @@ function deriveRegion(host) {
|
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
function request(uri, options, callback) {
|
|
218
|
-
if (typeof options === 'function') {
|
|
219
|
-
callback = options;
|
|
220
|
-
options = {};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
224
|
options = Object.assign(
|
|
224
225
|
{
|
|
225
226
|
method: 'GET',
|
|
@@ -604,6 +604,7 @@ Pool.prototype.logout = function(dbName, callback) {
|
|
|
604
604
|
/**
|
|
605
605
|
* Unref the pool
|
|
606
606
|
* @method
|
|
607
|
+
* @deprecated This function is deprecated and will be removed in the next major version.
|
|
607
608
|
*/
|
|
608
609
|
Pool.prototype.unref = function() {
|
|
609
610
|
// Get all the known connections
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const parsePackageVersion = require('../../utils').parsePackageVersion;
|
|
4
|
+
const MongoError = require('../error').MongoError;
|
|
5
|
+
|
|
3
6
|
const require_optional = require('optional-require')(require);
|
|
4
7
|
|
|
5
8
|
function debugOptions(debugFields, options) {
|
|
@@ -16,7 +19,15 @@ function retrieveBSON() {
|
|
|
16
19
|
BSON.native = false;
|
|
17
20
|
|
|
18
21
|
const optionalBSON = require_optional('bson-ext');
|
|
22
|
+
const bsonExtVersion = parsePackageVersion(
|
|
23
|
+
require_optional('bson-ext/package.json') || { version: '0.0.0' }
|
|
24
|
+
);
|
|
19
25
|
if (optionalBSON) {
|
|
26
|
+
if (bsonExtVersion.major >= 4) {
|
|
27
|
+
throw new MongoError(
|
|
28
|
+
'bson-ext version 4 and above does not work with the 3.x version of the mongodb driver'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
20
31
|
optionalBSON.native = true;
|
|
21
32
|
return optionalBSON;
|
|
22
33
|
}
|
|
@@ -31,21 +42,43 @@ function noSnappyWarning() {
|
|
|
31
42
|
);
|
|
32
43
|
}
|
|
33
44
|
|
|
45
|
+
const PKG_VERSION = Symbol('kPkgVersion');
|
|
46
|
+
|
|
34
47
|
// Facilitate loading Snappy optionally
|
|
35
48
|
function retrieveSnappy() {
|
|
36
|
-
|
|
49
|
+
const snappy = require_optional('snappy');
|
|
37
50
|
if (!snappy) {
|
|
38
|
-
|
|
51
|
+
return {
|
|
39
52
|
compress: noSnappyWarning,
|
|
40
53
|
uncompress: noSnappyWarning,
|
|
41
54
|
compressSync: noSnappyWarning,
|
|
42
55
|
uncompressSync: noSnappyWarning
|
|
43
56
|
};
|
|
44
57
|
}
|
|
58
|
+
|
|
59
|
+
const snappyPkg = require_optional('snappy/package.json') || { version: '0.0.0' };
|
|
60
|
+
const version = parsePackageVersion(snappyPkg);
|
|
61
|
+
snappy[PKG_VERSION] = version;
|
|
62
|
+
if (version.major >= 7) {
|
|
63
|
+
const compressOriginal = snappy.compress;
|
|
64
|
+
const uncompressOriginal = snappy.uncompress;
|
|
65
|
+
snappy.compress = (data, callback) => {
|
|
66
|
+
compressOriginal(data)
|
|
67
|
+
.then(res => callback(undefined, res))
|
|
68
|
+
.catch(error => callback(error));
|
|
69
|
+
};
|
|
70
|
+
snappy.uncompress = (data, callback) => {
|
|
71
|
+
uncompressOriginal(data)
|
|
72
|
+
.then(res => callback(undefined, res))
|
|
73
|
+
.catch(error => callback(error));
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
45
77
|
return snappy;
|
|
46
78
|
}
|
|
47
79
|
|
|
48
80
|
module.exports = {
|
|
81
|
+
PKG_VERSION,
|
|
49
82
|
debugOptions,
|
|
50
83
|
retrieveBSON,
|
|
51
84
|
retrieveSnappy
|
|
@@ -742,8 +742,11 @@ class Topology extends EventEmitter {
|
|
|
742
742
|
return this.s.state === STATE_CLOSED;
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
+
/**
|
|
746
|
+
* @deprecated This function is deprecated and will be removed in the next major version.
|
|
747
|
+
*/
|
|
745
748
|
unref() {
|
|
746
|
-
emitWarning('
|
|
749
|
+
emitWarning('`unref` is a noop and will be removed in the next major version');
|
|
747
750
|
}
|
|
748
751
|
|
|
749
752
|
// NOTE: There are many places in code where we explicitly check the last isMaster
|
package/lib/db.js
CHANGED
|
@@ -951,6 +951,7 @@ Db.prototype.indexInformation = function(name, options, callback) {
|
|
|
951
951
|
/**
|
|
952
952
|
* Unref all sockets
|
|
953
953
|
* @method
|
|
954
|
+
* @deprecated This function is deprecated and will be removed in the next major version.
|
|
954
955
|
*/
|
|
955
956
|
Db.prototype.unref = function() {
|
|
956
957
|
this.s.topology.unref();
|
package/lib/utils.js
CHANGED
|
@@ -946,6 +946,14 @@ function deepCopy(value) {
|
|
|
946
946
|
|
|
947
947
|
return value;
|
|
948
948
|
}
|
|
949
|
+
/**
|
|
950
|
+
* @param {{version: string}} pkg
|
|
951
|
+
* @returns {{ major: number; minor: number; patch: number }}
|
|
952
|
+
*/
|
|
953
|
+
function parsePackageVersion(pkg) {
|
|
954
|
+
const versionParts = pkg.version.split('.').map(n => Number.parseInt(n, 10));
|
|
955
|
+
return { major: versionParts[0], minor: versionParts[1], patch: versionParts[2] };
|
|
956
|
+
}
|
|
949
957
|
|
|
950
958
|
module.exports = {
|
|
951
959
|
filterOptions,
|
|
@@ -984,5 +992,6 @@ module.exports = {
|
|
|
984
992
|
MONGODB_WARNING_CODE,
|
|
985
993
|
emitWarning,
|
|
986
994
|
emitWarningOnce,
|
|
987
|
-
deepCopy
|
|
995
|
+
deepCopy,
|
|
996
|
+
parsePackageVersion
|
|
988
997
|
};
|