mongodb 3.5.11 → 3.6.2

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.
Files changed (68) hide show
  1. package/HISTORY.md +42 -21
  2. package/lib/admin.js +1 -0
  3. package/lib/bulk/common.js +48 -4
  4. package/lib/change_stream.js +0 -1
  5. package/lib/cmap/connection.js +9 -6
  6. package/lib/cmap/connection_pool.js +4 -10
  7. package/lib/collection.js +59 -81
  8. package/lib/core/auth/auth_provider.js +29 -132
  9. package/lib/core/auth/defaultAuthProviders.js +2 -2
  10. package/lib/core/auth/gssapi.js +124 -214
  11. package/lib/core/auth/mongo_credentials.js +29 -3
  12. package/lib/core/auth/mongocr.js +6 -12
  13. package/lib/core/auth/mongodb_aws.js +256 -0
  14. package/lib/core/auth/plain.js +5 -12
  15. package/lib/core/auth/scram.js +229 -212
  16. package/lib/core/auth/x509.js +25 -16
  17. package/lib/core/connection/connect.js +97 -161
  18. package/lib/core/connection/connection.js +71 -3
  19. package/lib/core/connection/pool.js +2 -2
  20. package/lib/core/cursor.js +18 -11
  21. package/lib/core/error.js +82 -8
  22. package/lib/core/sdam/common.js +8 -0
  23. package/lib/core/sdam/monitor.js +240 -78
  24. package/lib/core/sdam/server.js +81 -15
  25. package/lib/core/sdam/server_description.js +37 -2
  26. package/lib/core/sdam/topology.js +41 -8
  27. package/lib/core/sdam/topology_description.js +21 -3
  28. package/lib/core/sessions.js +38 -51
  29. package/lib/core/topologies/mongos.js +18 -6
  30. package/lib/core/topologies/read_preference.js +15 -3
  31. package/lib/core/topologies/replset.js +4 -4
  32. package/lib/core/topologies/server.js +1 -1
  33. package/lib/core/topologies/shared.js +39 -16
  34. package/lib/core/uri_parser.js +41 -6
  35. package/lib/core/utils.js +30 -0
  36. package/lib/core/wireprotocol/command.js +1 -4
  37. package/lib/core/wireprotocol/constants.js +2 -2
  38. package/lib/core/wireprotocol/query.js +4 -0
  39. package/lib/cursor.js +0 -1
  40. package/lib/db.js +6 -5
  41. package/lib/error.js +6 -1
  42. package/lib/gridfs-stream/download.js +13 -2
  43. package/lib/mongo_client.js +6 -4
  44. package/lib/operations/collection_ops.js +0 -20
  45. package/lib/operations/command_v2.js +1 -1
  46. package/lib/operations/common_functions.js +3 -0
  47. package/lib/operations/connect.js +11 -14
  48. package/lib/operations/create_collection.js +37 -52
  49. package/lib/operations/create_indexes.js +111 -35
  50. package/lib/operations/find.js +7 -1
  51. package/lib/operations/find_and_modify.js +17 -0
  52. package/lib/operations/find_one_and_delete.js +5 -0
  53. package/lib/operations/find_one_and_replace.js +13 -0
  54. package/lib/operations/find_one_and_update.js +13 -0
  55. package/lib/operations/map_reduce.js +1 -1
  56. package/lib/operations/re_index.js +22 -17
  57. package/lib/operations/replace_one.js +11 -4
  58. package/lib/operations/update_many.js +5 -0
  59. package/lib/operations/update_one.js +5 -0
  60. package/lib/operations/validate_collection.js +1 -2
  61. package/lib/topologies/mongos.js +1 -1
  62. package/lib/topologies/replset.js +1 -1
  63. package/lib/topologies/server.js +1 -1
  64. package/lib/utils.js +18 -1
  65. package/lib/write_concern.js +10 -0
  66. package/package.json +1 -1
  67. package/lib/core/auth/sspi.js +0 -131
  68. package/lib/operations/create_index.js +0 -92
@@ -1,131 +0,0 @@
1
- 'use strict';
2
-
3
- const AuthProvider = require('./auth_provider').AuthProvider;
4
- const retrieveKerberos = require('../utils').retrieveKerberos;
5
- let kerberos;
6
-
7
- /**
8
- * Creates a new SSPI authentication mechanism
9
- * @class
10
- * @extends AuthProvider
11
- */
12
- class SSPI extends AuthProvider {
13
- /**
14
- * Implementation of authentication for a single connection
15
- * @override
16
- */
17
- _authenticateSingleConnection(sendAuthCommand, connection, credentials, callback) {
18
- // TODO: Destructure this
19
- const username = credentials.username;
20
- const password = credentials.password;
21
- const mechanismProperties = credentials.mechanismProperties;
22
- const gssapiServiceName =
23
- mechanismProperties['gssapiservicename'] ||
24
- mechanismProperties['gssapiServiceName'] ||
25
- 'mongodb';
26
-
27
- SSIPAuthenticate(
28
- this,
29
- kerberos.processes.MongoAuthProcess,
30
- username,
31
- password,
32
- gssapiServiceName,
33
- sendAuthCommand,
34
- connection,
35
- mechanismProperties,
36
- callback
37
- );
38
- }
39
-
40
- /**
41
- * Authenticate
42
- * @override
43
- * @method
44
- */
45
- auth(sendAuthCommand, connections, credentials, callback) {
46
- if (kerberos == null) {
47
- try {
48
- kerberos = retrieveKerberos();
49
- } catch (e) {
50
- return callback(e, null);
51
- }
52
- }
53
-
54
- super.auth(sendAuthCommand, connections, credentials, callback);
55
- }
56
- }
57
-
58
- function SSIPAuthenticate(
59
- self,
60
- MongoAuthProcess,
61
- username,
62
- password,
63
- gssapiServiceName,
64
- sendAuthCommand,
65
- connection,
66
- options,
67
- callback
68
- ) {
69
- const authProcess = new MongoAuthProcess(
70
- connection.host,
71
- connection.port,
72
- gssapiServiceName,
73
- options
74
- );
75
-
76
- function authCommand(command, authCb) {
77
- sendAuthCommand(connection, '$external.$cmd', command, authCb);
78
- }
79
-
80
- authProcess.init(username, password, err => {
81
- if (err) return callback(err, false);
82
-
83
- authProcess.transition('', (err, payload) => {
84
- if (err) return callback(err, false);
85
-
86
- const command = {
87
- saslStart: 1,
88
- mechanism: 'GSSAPI',
89
- payload,
90
- autoAuthorize: 1
91
- };
92
-
93
- authCommand(command, (err, doc) => {
94
- if (err) return callback(err, false);
95
-
96
- authProcess.transition(doc.payload, (err, payload) => {
97
- if (err) return callback(err, false);
98
- const command = {
99
- saslContinue: 1,
100
- conversationId: doc.conversationId,
101
- payload
102
- };
103
-
104
- authCommand(command, (err, doc) => {
105
- if (err) return callback(err, false);
106
-
107
- authProcess.transition(doc.payload, (err, payload) => {
108
- if (err) return callback(err, false);
109
- const command = {
110
- saslContinue: 1,
111
- conversationId: doc.conversationId,
112
- payload
113
- };
114
-
115
- authCommand(command, (err, response) => {
116
- if (err) return callback(err, false);
117
-
118
- authProcess.transition(null, err => {
119
- if (err) return callback(err, null);
120
- callback(null, response);
121
- });
122
- });
123
- });
124
- });
125
- });
126
- });
127
- });
128
- });
129
- }
130
-
131
- module.exports = SSPI;
@@ -1,92 +0,0 @@
1
- 'use strict';
2
-
3
- const Aspect = require('./operation').Aspect;
4
- const CommandOperation = require('./command');
5
- const defineAspects = require('./operation').defineAspects;
6
- const handleCallback = require('../utils').handleCallback;
7
- const MongoError = require('../core').MongoError;
8
- const parseIndexOptions = require('../utils').parseIndexOptions;
9
-
10
- const keysToOmit = new Set([
11
- 'name',
12
- 'key',
13
- 'writeConcern',
14
- 'w',
15
- 'wtimeout',
16
- 'j',
17
- 'fsync',
18
- 'readPreference',
19
- 'session'
20
- ]);
21
-
22
- class CreateIndexOperation extends CommandOperation {
23
- constructor(db, name, fieldOrSpec, options) {
24
- super(db, options);
25
-
26
- // Build the index
27
- const indexParameters = parseIndexOptions(fieldOrSpec);
28
- // Generate the index name
29
- const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
30
- // Set up the index
31
- const indexesObject = { name: indexName, key: indexParameters.fieldHash };
32
-
33
- this.name = name;
34
- this.fieldOrSpec = fieldOrSpec;
35
- this.indexes = indexesObject;
36
- }
37
-
38
- _buildCommand() {
39
- const options = this.options;
40
- const name = this.name;
41
- const indexes = this.indexes;
42
-
43
- // merge all the options
44
- for (let optionName in options) {
45
- if (!keysToOmit.has(optionName)) {
46
- indexes[optionName] = options[optionName];
47
- }
48
- }
49
-
50
- // Create command, apply write concern to command
51
- const cmd = { createIndexes: name, indexes: [indexes] };
52
-
53
- return cmd;
54
- }
55
-
56
- execute(callback) {
57
- const db = this.db;
58
- const options = this.options;
59
- const indexes = this.indexes;
60
-
61
- // Get capabilities
62
- const capabilities = db.s.topology.capabilities();
63
-
64
- // Did the user pass in a collation, check if our write server supports it
65
- if (options.collation && capabilities && !capabilities.commandsTakeCollation) {
66
- // Create a new error
67
- const error = new MongoError('server/primary/mongos does not support collation');
68
- error.code = 67;
69
- // Return the error
70
- return callback(error);
71
- }
72
-
73
- // Ensure we have a callback
74
- if (options.writeConcern && typeof callback !== 'function') {
75
- throw MongoError.create({
76
- message: 'Cannot use a writeConcern without a provided callback',
77
- driver: true
78
- });
79
- }
80
-
81
- // Attempt to run using createIndexes command
82
- super.execute((err, result) => {
83
- if (err == null) return handleCallback(callback, err, indexes.name);
84
-
85
- return handleCallback(callback, err, result);
86
- });
87
- }
88
- }
89
-
90
- defineAspects(CreateIndexOperation, Aspect.WRITE_OPERATION);
91
-
92
- module.exports = CreateIndexOperation;