mongodb 5.0.1 → 5.2.0

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 (146) hide show
  1. package/README.md +25 -22
  2. package/lib/bson.js +3 -1
  3. package/lib/bson.js.map +1 -1
  4. package/lib/change_stream.js +3 -2
  5. package/lib/change_stream.js.map +1 -1
  6. package/lib/cmap/auth/auth_provider.js +21 -10
  7. package/lib/cmap/auth/auth_provider.js.map +1 -1
  8. package/lib/cmap/auth/gssapi.js +71 -116
  9. package/lib/cmap/auth/gssapi.js.map +1 -1
  10. package/lib/cmap/auth/mongo_credentials.js +17 -0
  11. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  12. package/lib/cmap/auth/mongocr.js +20 -29
  13. package/lib/cmap/auth/mongocr.js.map +1 -1
  14. package/lib/cmap/auth/mongodb_aws.js +126 -140
  15. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  16. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +28 -0
  17. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -0
  18. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +178 -0
  19. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
  20. package/lib/cmap/auth/mongodb_oidc/service_workflow.js +41 -0
  21. package/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -0
  22. package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js +115 -0
  23. package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js.map +1 -0
  24. package/lib/cmap/auth/mongodb_oidc/workflow.js +3 -0
  25. package/lib/cmap/auth/mongodb_oidc/workflow.js.map +1 -0
  26. package/lib/cmap/auth/mongodb_oidc.js +62 -0
  27. package/lib/cmap/auth/mongodb_oidc.js.map +1 -0
  28. package/lib/cmap/auth/plain.js +4 -5
  29. package/lib/cmap/auth/plain.js.map +1 -1
  30. package/lib/cmap/auth/providers.js +4 -1
  31. package/lib/cmap/auth/providers.js.map +1 -1
  32. package/lib/cmap/auth/scram.js +45 -73
  33. package/lib/cmap/auth/scram.js.map +1 -1
  34. package/lib/cmap/auth/x509.js +8 -11
  35. package/lib/cmap/auth/x509.js.map +1 -1
  36. package/lib/cmap/command_monitoring_events.js +8 -5
  37. package/lib/cmap/command_monitoring_events.js.map +1 -1
  38. package/lib/cmap/commands.js +9 -1
  39. package/lib/cmap/commands.js.map +1 -1
  40. package/lib/cmap/connect.js +72 -86
  41. package/lib/cmap/connect.js.map +1 -1
  42. package/lib/cmap/connection.js +68 -74
  43. package/lib/cmap/connection.js.map +1 -1
  44. package/lib/cmap/connection_pool.js +51 -13
  45. package/lib/cmap/connection_pool.js.map +1 -1
  46. package/lib/cmap/message_stream.js.map +1 -1
  47. package/lib/cmap/wire_protocol/shared.js +1 -16
  48. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  49. package/lib/collection.js +10 -10
  50. package/lib/connection_string.js +47 -33
  51. package/lib/connection_string.js.map +1 -1
  52. package/lib/cursor/abstract_cursor.js +13 -7
  53. package/lib/cursor/abstract_cursor.js.map +1 -1
  54. package/lib/cursor/find_cursor.js +1 -1
  55. package/lib/db.js +3 -2
  56. package/lib/db.js.map +1 -1
  57. package/lib/error.js +2 -1
  58. package/lib/error.js.map +1 -1
  59. package/lib/mongo_client.js +22 -2
  60. package/lib/mongo_client.js.map +1 -1
  61. package/lib/mongo_logger.js +17 -1
  62. package/lib/mongo_logger.js.map +1 -1
  63. package/lib/operations/aggregate.js +4 -1
  64. package/lib/operations/aggregate.js.map +1 -1
  65. package/lib/operations/create_collection.js +1 -0
  66. package/lib/operations/create_collection.js.map +1 -1
  67. package/lib/operations/execute_operation.js +8 -27
  68. package/lib/operations/execute_operation.js.map +1 -1
  69. package/lib/operations/find.js +3 -2
  70. package/lib/operations/find.js.map +1 -1
  71. package/lib/operations/indexes.js +2 -1
  72. package/lib/operations/indexes.js.map +1 -1
  73. package/lib/operations/list_collections.js +2 -1
  74. package/lib/operations/list_collections.js.map +1 -1
  75. package/lib/read_concern.js +1 -1
  76. package/lib/read_preference.js +2 -2
  77. package/lib/sdam/monitor.js +1 -0
  78. package/lib/sdam/monitor.js.map +1 -1
  79. package/lib/sdam/server.js +4 -2
  80. package/lib/sdam/server.js.map +1 -1
  81. package/lib/sdam/topology.js +3 -26
  82. package/lib/sdam/topology.js.map +1 -1
  83. package/lib/sessions.js +2 -1
  84. package/lib/sessions.js.map +1 -1
  85. package/lib/utils.js +15 -70
  86. package/lib/utils.js.map +1 -1
  87. package/lib/write_concern.js +1 -1
  88. package/mongodb.d.ts +137 -68
  89. package/package.json +30 -30
  90. package/src/bson.ts +3 -1
  91. package/src/bulk/common.ts +1 -1
  92. package/src/change_stream.ts +16 -8
  93. package/src/cmap/auth/auth_provider.ts +29 -16
  94. package/src/cmap/auth/gssapi.ts +102 -149
  95. package/src/cmap/auth/mongo_credentials.ts +47 -1
  96. package/src/cmap/auth/mongocr.ts +31 -36
  97. package/src/cmap/auth/mongodb_aws.ts +167 -189
  98. package/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +26 -0
  99. package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +259 -0
  100. package/src/cmap/auth/mongodb_oidc/service_workflow.ts +47 -0
  101. package/src/cmap/auth/mongodb_oidc/token_entry_cache.ts +166 -0
  102. package/src/cmap/auth/mongodb_oidc/workflow.ts +21 -0
  103. package/src/cmap/auth/mongodb_oidc.ts +123 -0
  104. package/src/cmap/auth/plain.ts +6 -6
  105. package/src/cmap/auth/providers.ts +5 -2
  106. package/src/cmap/auth/scram.ts +56 -90
  107. package/src/cmap/auth/x509.ts +12 -18
  108. package/src/cmap/command_monitoring_events.ts +5 -2
  109. package/src/cmap/commands.ts +11 -1
  110. package/src/cmap/connect.ts +90 -114
  111. package/src/cmap/connection.ts +92 -90
  112. package/src/cmap/connection_pool.ts +77 -16
  113. package/src/cmap/message_stream.ts +0 -2
  114. package/src/cmap/wire_protocol/compression.ts +1 -1
  115. package/src/cmap/wire_protocol/shared.ts +1 -23
  116. package/src/collection.ts +11 -11
  117. package/src/connection_string.ts +52 -35
  118. package/src/cursor/abstract_cursor.ts +13 -6
  119. package/src/cursor/change_stream_cursor.ts +5 -5
  120. package/src/cursor/find_cursor.ts +1 -1
  121. package/src/db.ts +3 -2
  122. package/src/deps.ts +56 -38
  123. package/src/error.ts +3 -2
  124. package/src/index.ts +7 -0
  125. package/src/mongo_client.ts +35 -10
  126. package/src/mongo_logger.ts +20 -2
  127. package/src/mongo_types.ts +4 -3
  128. package/src/operations/aggregate.ts +4 -2
  129. package/src/operations/create_collection.ts +2 -1
  130. package/src/operations/execute_operation.ts +8 -25
  131. package/src/operations/find.ts +13 -4
  132. package/src/operations/find_and_modify.ts +4 -4
  133. package/src/operations/indexes.ts +12 -4
  134. package/src/operations/list_collections.ts +11 -3
  135. package/src/operations/set_profiling_level.ts +1 -1
  136. package/src/operations/stats.ts +1 -1
  137. package/src/read_concern.ts +2 -2
  138. package/src/read_preference.ts +3 -3
  139. package/src/sdam/common.ts +2 -2
  140. package/src/sdam/monitor.ts +1 -0
  141. package/src/sdam/server.ts +4 -1
  142. package/src/sdam/topology.ts +4 -33
  143. package/src/sessions.ts +2 -1
  144. package/src/transactions.ts +1 -1
  145. package/src/utils.ts +24 -98
  146. package/src/write_concern.ts +1 -1
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallbackWorkflow = void 0;
4
+ const bson_1 = require("bson");
5
+ const error_1 = require("../../../error");
6
+ const utils_1 = require("../../../utils");
7
+ const providers_1 = require("../providers");
8
+ const token_entry_cache_1 = require("./token_entry_cache");
9
+ /* 5 minutes in milliseconds */
10
+ const TIMEOUT_MS = 300000;
11
+ /**
12
+ * OIDC implementation of a callback based workflow.
13
+ * @internal
14
+ */
15
+ class CallbackWorkflow {
16
+ /**
17
+ * Instantiate the workflow
18
+ */
19
+ constructor() {
20
+ this.cache = new token_entry_cache_1.TokenEntryCache();
21
+ }
22
+ /**
23
+ * Get the document to add for speculative authentication. Is empty when
24
+ * callbacks are in play.
25
+ */
26
+ speculativeAuth() {
27
+ return Promise.resolve({});
28
+ }
29
+ /**
30
+ * Execute the workflow.
31
+ *
32
+ * Steps:
33
+ * - If an entry is in the cache
34
+ * - If it is not expired
35
+ * - Skip step one and use the entry to execute step two.
36
+ * - If it is expired
37
+ * - If the refresh callback exists
38
+ * - remove expired entry from cache
39
+ * - call the refresh callback.
40
+ * - put the new entry in the cache.
41
+ * - execute step two.
42
+ * - If the refresh callback does not exist.
43
+ * - remove expired entry from cache
44
+ * - call the request callback.
45
+ * - put the new entry in the cache.
46
+ * - execute step two.
47
+ * - If no entry is in the cache.
48
+ * - execute step one.
49
+ * - call the refresh callback.
50
+ * - put the new entry in the cache.
51
+ * - execute step two.
52
+ */
53
+ async execute(connection, credentials, reauthenticate = false) {
54
+ const request = credentials.mechanismProperties.REQUEST_TOKEN_CALLBACK;
55
+ const refresh = credentials.mechanismProperties.REFRESH_TOKEN_CALLBACK;
56
+ const entry = this.cache.getEntry(connection.address, credentials.username, request || null, refresh || null);
57
+ if (entry) {
58
+ // Check if the entry is not expired and if we are reauthenticating.
59
+ if (!reauthenticate && entry.isValid()) {
60
+ // Skip step one and execute the step two saslContinue.
61
+ try {
62
+ const result = await finishAuth(entry.tokenResult, undefined, connection, credentials);
63
+ return result;
64
+ }
65
+ catch (error) {
66
+ // If authentication errors when using a cached token we remove it from
67
+ // the cache.
68
+ this.cache.deleteEntry(connection.address, credentials.username || '', request || null, refresh || null);
69
+ throw error;
70
+ }
71
+ }
72
+ else {
73
+ // Remove the expired entry from the cache.
74
+ this.cache.deleteEntry(connection.address, credentials.username || '', request || null, refresh || null);
75
+ // Execute a refresh of the token and finish auth.
76
+ return this.refreshAndFinish(connection, credentials, entry.serverResult, entry.tokenResult);
77
+ }
78
+ }
79
+ else {
80
+ // No entry means to start with the step one saslStart.
81
+ const result = await connection.commandAsync((0, utils_1.ns)(credentials.source), startCommandDocument(credentials), undefined);
82
+ const stepOne = bson_1.BSON.deserialize(result.payload.buffer);
83
+ // Call the request callback and finish auth.
84
+ return this.requestAndFinish(connection, credentials, stepOne, result.conversationId);
85
+ }
86
+ }
87
+ /**
88
+ * Execute the refresh callback if it exists, otherwise the request callback, then
89
+ * finish the authentication.
90
+ */
91
+ async refreshAndFinish(connection, credentials, stepOneResult, tokenResult, conversationId) {
92
+ const request = credentials.mechanismProperties.REQUEST_TOKEN_CALLBACK;
93
+ const refresh = credentials.mechanismProperties.REFRESH_TOKEN_CALLBACK;
94
+ // If a refresh callback exists, use it. Otherwise use the request callback.
95
+ if (refresh) {
96
+ const result = await refresh(credentials.username, stepOneResult, tokenResult, TIMEOUT_MS);
97
+ // Validate the result.
98
+ if (!result || !result.accessToken) {
99
+ throw new error_1.MongoMissingCredentialsError('REFRESH_TOKEN_CALLBACK must return a valid object with an accessToken');
100
+ }
101
+ // Cache a new entry and continue with the saslContinue.
102
+ this.cache.addEntry(connection.address, credentials.username || '', request || null, refresh, result, stepOneResult);
103
+ return finishAuth(result, conversationId, connection, credentials);
104
+ }
105
+ else {
106
+ // Fallback to using the request callback.
107
+ return this.requestAndFinish(connection, credentials, stepOneResult, conversationId);
108
+ }
109
+ }
110
+ /**
111
+ * Execute the request callback and finish authentication.
112
+ */
113
+ async requestAndFinish(connection, credentials, stepOneResult, conversationId) {
114
+ // Call the request callback.
115
+ const request = credentials.mechanismProperties.REQUEST_TOKEN_CALLBACK;
116
+ const refresh = credentials.mechanismProperties.REFRESH_TOKEN_CALLBACK;
117
+ // Always clear expired entries from the cache on each finish as cleanup.
118
+ this.cache.deleteExpiredEntries();
119
+ if (!request) {
120
+ // Request callback must be present.
121
+ throw new error_1.MongoInvalidArgumentError('Auth mechanism property REQUEST_TOKEN_CALLBACK is required.');
122
+ }
123
+ const tokenResult = await request(credentials.username, stepOneResult, TIMEOUT_MS);
124
+ // Validate the result.
125
+ if (!tokenResult || !tokenResult.accessToken) {
126
+ throw new error_1.MongoMissingCredentialsError('REQUEST_TOKEN_CALLBACK must return a valid object with an accessToken');
127
+ }
128
+ // Cache a new entry and continue with the saslContinue.
129
+ this.cache.addEntry(connection.address, credentials.username || '', request, refresh || null, tokenResult, stepOneResult);
130
+ return finishAuth(tokenResult, conversationId, connection, credentials);
131
+ }
132
+ }
133
+ exports.CallbackWorkflow = CallbackWorkflow;
134
+ /**
135
+ * Cache the result of the user supplied callback and execute the
136
+ * step two saslContinue.
137
+ */
138
+ async function finishAuth(result, conversationId, connection, credentials) {
139
+ // Execute the step two saslContinue.
140
+ return connection.commandAsync((0, utils_1.ns)(credentials.source), continueCommandDocument(result.accessToken, conversationId), undefined);
141
+ }
142
+ /**
143
+ * Generate the saslStart command document.
144
+ */
145
+ function startCommandDocument(credentials) {
146
+ const payload = {};
147
+ if (credentials.username) {
148
+ payload.n = credentials.username;
149
+ }
150
+ return {
151
+ saslStart: 1,
152
+ autoAuthorize: 1,
153
+ mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
154
+ payload: new bson_1.Binary(bson_1.BSON.serialize(payload))
155
+ };
156
+ }
157
+ /**
158
+ * Generate the saslContinue command document.
159
+ */
160
+ function continueCommandDocument(token, conversationId) {
161
+ if (conversationId) {
162
+ return {
163
+ saslContinue: 1,
164
+ conversationId: conversationId,
165
+ payload: new bson_1.Binary(bson_1.BSON.serialize({ jwt: token }))
166
+ };
167
+ }
168
+ // saslContinue requires a conversationId in the command to be valid so in this
169
+ // case the server allows "step two" to actually be a saslStart with the token
170
+ // as the jwt since the use of the cached value has no correlating conversating
171
+ // on the particular connection.
172
+ return {
173
+ saslStart: 1,
174
+ mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
175
+ payload: new bson_1.Binary(bson_1.BSON.serialize({ jwt: token }))
176
+ };
177
+ }
178
+ //# sourceMappingURL=callback_workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback_workflow.js","sourceRoot":"","sources":["../../../../src/cmap/auth/mongodb_oid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CAAC,WAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;KACpD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commandDocument = exports.ServiceWorkflow = void 0;
4
+ const bson_1 = require("bson");
5
+ const utils_1 = require("../../../utils");
6
+ const providers_1 = require("../providers");
7
+ /**
8
+ * Common behaviour for OIDC device workflows.
9
+ * @internal
10
+ */
11
+ class ServiceWorkflow {
12
+ /**
13
+ * Execute the workflow. Looks for AWS_WEB_IDENTITY_TOKEN_FILE in the environment
14
+ * and then attempts to read the token from that path.
15
+ */
16
+ async execute(connection, credentials) {
17
+ const token = await this.getToken();
18
+ const command = commandDocument(token);
19
+ return connection.commandAsync((0, utils_1.ns)(credentials.source), command, undefined);
20
+ }
21
+ /**
22
+ * Get the document to add for speculative authentication.
23
+ */
24
+ async speculativeAuth() {
25
+ const token = await this.getToken();
26
+ return { speculativeAuthenticate: commandDocument(token) };
27
+ }
28
+ }
29
+ exports.ServiceWorkflow = ServiceWorkflow;
30
+ /**
31
+ * Create the saslStart command document.
32
+ */
33
+ function commandDocument(token) {
34
+ return {
35
+ saslStart: 1,
36
+ mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
37
+ payload: bson_1.BSON.serialize({ jwt: token })
38
+ };
39
+ }
40
+ exports.commandDocument = commandDocument;
41
+ //# sourceMappingURL=service_workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service_workflow.js","sourceRoot":"","sources":["../../../../src/cmap/auth/mongodb_oidc/service_workflow.ts"],"names":[],"mappings":";;;AAAA,+BAA2C;AAE3C,0CAAoC;AAGpC,4CAA6C;AAG7C;;;GAGG;AACH,MAAsB,eAAe;IACnC;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,UAAsB,EAAE,WAA6B;QACjE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC,YAAY,CAAC,IAAA,UAAE,EAAC,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,OAAO,EAAE,uBAAuB,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7D,CAAC;CAMF;AAvBD,0CAuBC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,KAAa;IAC3C,OAAO;QACL,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,yBAAa,CAAC,YAAY;QACrC,OAAO,EAAE,WAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;KACxC,CAAC;AACJ,CAAC;AAND,0CAMC"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenEntryCache = exports.TokenEntry = void 0;
4
+ /* 5 minutes in milliseonds */
5
+ const EXPIRATION_BUFFER_MS = 300000;
6
+ /* Default expiration is now for when no expiration provided */
7
+ const DEFAULT_EXPIRATION_SECS = 0;
8
+ /* Counter for function "hashes".*/
9
+ let FN_HASH_COUNTER = 0;
10
+ /* No function present function */
11
+ const NO_FUNCTION = () => {
12
+ return Promise.resolve({ accessToken: 'test' });
13
+ };
14
+ /* The map of function hashes */
15
+ const FN_HASHES = new WeakMap();
16
+ /* Put the no function hash in the map. */
17
+ FN_HASHES.set(NO_FUNCTION, FN_HASH_COUNTER);
18
+ /** @internal */
19
+ class TokenEntry {
20
+ /**
21
+ * Instantiate the entry.
22
+ */
23
+ constructor(tokenResult, serverResult, expiration) {
24
+ this.tokenResult = tokenResult;
25
+ this.serverResult = serverResult;
26
+ this.expiration = expiration;
27
+ }
28
+ /**
29
+ * The entry is still valid if the expiration is more than
30
+ * 5 minutes from the expiration time.
31
+ */
32
+ isValid() {
33
+ return this.expiration - Date.now() > EXPIRATION_BUFFER_MS;
34
+ }
35
+ }
36
+ exports.TokenEntry = TokenEntry;
37
+ /**
38
+ * Cache of OIDC token entries.
39
+ * @internal
40
+ */
41
+ class TokenEntryCache {
42
+ constructor() {
43
+ this.entries = new Map();
44
+ }
45
+ /**
46
+ * Set an entry in the token cache.
47
+ */
48
+ addEntry(address, username, requestFn, refreshFn, tokenResult, serverResult) {
49
+ const entry = new TokenEntry(tokenResult, serverResult, expirationTime(tokenResult.expiresInSeconds));
50
+ this.entries.set(cacheKey(address, username, requestFn, refreshFn), entry);
51
+ return entry;
52
+ }
53
+ /**
54
+ * Clear the cache.
55
+ */
56
+ clear() {
57
+ this.entries.clear();
58
+ }
59
+ /**
60
+ * Delete an entry from the cache.
61
+ */
62
+ deleteEntry(address, username, requestFn, refreshFn) {
63
+ this.entries.delete(cacheKey(address, username, requestFn, refreshFn));
64
+ }
65
+ /**
66
+ * Get an entry from the cache.
67
+ */
68
+ getEntry(address, username, requestFn, refreshFn) {
69
+ return this.entries.get(cacheKey(address, username, requestFn, refreshFn));
70
+ }
71
+ /**
72
+ * Delete all expired entries from the cache.
73
+ */
74
+ deleteExpiredEntries() {
75
+ for (const [key, entry] of this.entries) {
76
+ if (!entry.isValid()) {
77
+ this.entries.delete(key);
78
+ }
79
+ }
80
+ }
81
+ }
82
+ exports.TokenEntryCache = TokenEntryCache;
83
+ /**
84
+ * Get an expiration time in milliseconds past epoch. Defaults to immediate.
85
+ */
86
+ function expirationTime(expiresInSeconds) {
87
+ return Date.now() + (expiresInSeconds ?? DEFAULT_EXPIRATION_SECS) * 1000;
88
+ }
89
+ /**
90
+ * Create a cache key from the address and username.
91
+ */
92
+ function cacheKey(address, username, requestFn, refreshFn) {
93
+ return `${address}-${username}-${hashFunctions(requestFn, refreshFn)}`;
94
+ }
95
+ /**
96
+ * Get the hash string for the request and refresh functions.
97
+ */
98
+ function hashFunctions(requestFn, refreshFn) {
99
+ let requestHash = FN_HASHES.get(requestFn || NO_FUNCTION);
100
+ let refreshHash = FN_HASHES.get(refreshFn || NO_FUNCTION);
101
+ if (!requestHash && requestFn) {
102
+ // Create a new one for the function and put it in the map.
103
+ FN_HASH_COUNTER++;
104
+ requestHash = FN_HASH_COUNTER;
105
+ FN_HASHES.set(requestFn, FN_HASH_COUNTER);
106
+ }
107
+ if (!refreshHash && refreshFn) {
108
+ // Create a new one for the function and put it in the map.
109
+ FN_HASH_COUNTER++;
110
+ refreshHash = FN_HASH_COUNTER;
111
+ FN_HASHES.set(refreshFn, FN_HASH_COUNTER);
112
+ }
113
+ return `${requestHash}-${refreshHash}`;
114
+ }
115
+ //# sourceMappingURL=token_entry_cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token_entry_cache.js","sourceRoot":"","sources":["../../../../src/cmap/auth/mongodb_oidc/token_entry_cache.ts"],"names":[],"mappings":";;;AAOA,8BAA8B;AAC9B,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,+DAA+D;AAC/D,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,mCAAmC;AACnC,IAAI,eAAe,GAAG,CAAC,CAAC;AACxB,kCAAkC;AAClC,MAAM,WAAW,GAAwB,GAAG,EAAE;IAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AACF,gCAAgC;AAChC,MAAM,SAAS,GAAG,IAAI,OAAO,EAAqD,CAAC;AACnF,0CAA0C;AAC1C,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAE5C,gBAAgB;AAChB,MAAa,UAAU;IAKrB;;OAEG;IACH,YACE,WAAmC,EACnC,YAAsC,EACtC,UAAkB;QAElB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,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ports, "__esModule", { value: true });
3
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../../src/cmap/auth/mongodb_oidc/workflow.ts"],"names":[],"mappings":""}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MongoDBOIDC = exports.OIDC_WORKFLOWS = void 0;
4
+ const error_1 = require("../../error");
5
+ const auth_provider_1 = require("./auth_provider");
6
+ const aws_service_workflow_1 = require("./mongodb_oidc/aws_service_workflow");
7
+ const callback_workflow_1 = require("./mongodb_oidc/callback_workflow");
8
+ /** @internal */
9
+ exports.OIDC_WORKFLOWS = new Map();
10
+ exports.OIDC_WORKFLOWS.set('callback', new callback_workflow_1.CallbackWorkflow());
11
+ exports.OIDC_WORKFLOWS.set('aws', new aws_service_workflow_1.AwsServiceWorkflow());
12
+ /**
13
+ * OIDC auth provider.
14
+ * @experimental
15
+ */
16
+ class MongoDBOIDC extends auth_provider_1.AuthProvider {
17
+ /**
18
+ * Instantiate the auth provider.
19
+ */
20
+ constructor() {
21
+ super();
22
+ }
23
+ /**
24
+ * Authenticate using OIDC
25
+ */
26
+ async auth(authContext) {
27
+ const { connection, credentials, response, reauthenticating } = authContext;
28
+ if (response?.speculativeAuthenticate) {
29
+ return;
30
+ }
31
+ if (!credentials) {
32
+ throw new error_1.MongoMissingCredentialsError('AuthContext must provide credentials.');
33
+ }
34
+ const workflow = getWorkflow(credentials);
35
+ await workflow.execute(connection, credentials, reauthenticating);
36
+ }
37
+ /**
38
+ * Add the speculative auth for the initial handshake.
39
+ */
40
+ async prepare(handshakeDoc, authContext) {
41
+ const { credentials } = authContext;
42
+ if (!credentials) {
43
+ throw new error_1.MongoMissingCredentialsError('AuthContext must provide credentials.');
44
+ }
45
+ const workflow = getWorkflow(credentials);
46
+ const result = await workflow.speculativeAuth();
47
+ return { ...handshakeDoc, ...result };
48
+ }
49
+ }
50
+ exports.MongoDBOIDC = MongoDBOIDC;
51
+ /**
52
+ * Gets either a device workflow or callback workflow.
53
+ */
54
+ function getWorkflow(credentials) {
55
+ const providerName = credentials.mechanismProperties.PROVIDER_NAME;
56
+ const workflow = exports.OIDC_WORKFLOWS.get(providerName || 'callback');
57
+ if (!workflow) {
58
+ throw new error_1.MongoInvalidArgumentError(`Could not load workflow for provider ${credentials.mechanismProperties.PROVIDER_NAME}`);
59
+ }
60
+ return workflow;
61
+ }
62
+ //# sourceMappingURL=mongodb_oidc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb_oidc.js","sourceRoot":"","sources":["../../../src/cmap/auth/mongodb_oidc.ts"],"names":[],"mappings":";;;AAAA,uCAAsF;AAEtF,mDAAiE;AAEjE,8EAAyE;AACzE,wEAAoE;AAiDpE,gBAAgB;AACH,QAAA,cAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;AACrE,sBAAc,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,oCAAgB,EAAE,CAAC,CAAC;AACvD,sBAAc,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,yCAAkB,EAAE,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAa,WAAY,SAAQ,4BAAY;IAC3C;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,IAAI,CAAC,WAAwB;QAC1C,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAC;QAE5E,IAAI,QAAQ,EAAE,uBAAuB,EAAE;YACrC,OAAO;SACR;QAED,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,oCAA4B,CAAC,uCAAuC,CAAC,CAAC;SACjF;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QAE1C,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,OAAO,CACpB,YAA+B,EAC/B,WAAwB;QAExB,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;QAEpC,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,oCAA4B,CAAC,uCAAuC,CAAC,CAAC;SACjF;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;QAChD,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACxC,CAAC;CACF;AA7CD,kCA6CC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,WAA6B;IAChD,MAAM,YAAY,GAAG,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC;IACnE,MAAM,QAAQ,GAAG,sBAAc,CAAC,GAAG,CAAC,YAAY,IAAI,UAAU,CAAC,CAAC;IAChE,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,iCAAyB,CACjC,wCAAwC,WAAW,CAAC,mBAAmB,CAAC,aAAa,EAAE,CACxF,CAAC;KACH;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -6,13 +6,12 @@ const error_1 = require("../../error");
6
6
  const utils_1 = require("../../utils");
7
7
  const auth_provider_1 = require("./auth_provider");
8
8
  class Plain extends auth_provider_1.AuthProvider {
9
- auth(authContext, callback) {
9
+ async auth(authContext) {
10
10
  const { connection, credentials } = authContext;
11
11
  if (!credentials) {
12
- return callback(new error_1.MongoMissingCredentialsError('AuthContext must provide credentials.'));
12
+ throw new error_1.MongoMissingCredentialsError('AuthContext must provide credentials.');
13
13
  }
14
- const username = credentials.username;
15
- const password = credentials.password;
14
+ const { username, password } = credentials;
16
15
  const payload = new bson_1.Binary(Buffer.from(`\x00${username}\x00${password}`));
17
16
  const command = {
18
17
  saslStart: 1,
@@ -20,7 +19,7 @@ class Plain extends auth_provider_1.AuthProvider {
20
19
  payload: payload,
21
20
  autoAuthorize: 1
22
21
  };
23
- connection.command((0, utils_1.ns)('$external.$cmd'), command, undefined, callback);
22
+ await connection.commandAsync((0, utils_1.ns)('$external.$cmd'), command, undefined);
24
23
  }
25
24
  }
26
25
  exports.Plain = Plain;
@@ -1 +1 @@
1
- {"version":3,"file":"plain.js","sourceRoot":"","sources":["../../../src/cmap/auth/plain.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,uCAA2D;AAC3D,uCAA2C;AAC3C,mDAA4D;AAE5D,MAAa,KAAM,SAAQ,4BAAY;IAC5B,IAAI,CAAC,WAAwB,EAAE,QAAkB;QACxD,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;QAChD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,QAAQ,CAAC,IAAI,oCAA4B,CAAC,uCAAuC,CAAC,CAAC,CAAC;SAC5F;QACD,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;QACtC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;QAEtC,MAAM,OAAO,GAAG,IAAI,aAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG;YACd,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,CAAC;SACjB,CAAC;QAEF,UAAU,CAAC,OAAO,CAAC,IAAA,UAAE,EAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;CACF;AAnBD,sBAmBC"}
1
+ {"version":3,"file":"plain.js","sourceRoot":"","sources":["../../../src/cmap/auth/plain.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,uCAA2D;AAC3D,uCAAiC;AACjC,mDAA4D;AAE5D,MAAa,KAAM,SAAQ,4BAAY;IAC5B,KAAK,CAAC,IAAI,CAAC,WAAwB;QAC1C,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;QAChD,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,oCAA4B,CAAC,uCAAuC,CAAC,CAAC;SACjF;QAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;QAE3C,MAAM,OAAO,GAAG,IAAI,aAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG;YACd,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,CAAC;SACjB,CAAC;QAEF,MAAM,UAAU,CAAC,YAAY,CAAC,IAAA,UAAE,EAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1E,CAAC;CACF;AAnBD,sBAmBC"}
@@ -10,12 +10,15 @@ exports.AuthMechanism = Object.freeze({
10
10
  MONGODB_PLAIN: 'PLAIN',
11
11
  MONGODB_SCRAM_SHA1: 'SCRAM-SHA-1',
12
12
  MONGODB_SCRAM_SHA256: 'SCRAM-SHA-256',
13
- MONGODB_X509: 'MONGODB-X509'
13
+ MONGODB_X509: 'MONGODB-X509',
14
+ /** @experimental */
15
+ MONGODB_OIDC: 'MONGODB-OIDC'
14
16
  });
15
17
  /** @internal */
16
18
  exports.AUTH_MECHS_AUTH_SRC_EXTERNAL = new Set([
17
19
  exports.AuthMechanism.MONGODB_GSSAPI,
18
20
  exports.AuthMechanism.MONGODB_AWS,
21
+ exports.AuthMechanism.MONGODB_OIDC,
19
22
  exports.AuthMechanism.MONGODB_X509
20
23
  ]);
21
24
  //# sourceMappingURL=providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/cmap/auth/providers.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,OAAO;IACtB,kBAAkB,EAAE,aAAa;IACjC,oBAAoB,EAAE,eAAe;IACrC,YAAY,EAAE,cAAc;CACpB,CAAC,CAAC;AAKZ,gBAAgB;AACH,QAAA,4BAA4B,GAAG,IAAI,GAAG,CAAgB;IACjE,qBAAa,CAAC,cAAc;IAC5B,qBAAa,CAAC,WAAW;IACzB,qBAAa,CAAC,YAAY;CAC3B,CAAC,CAAC"}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/cmap/auth/providers.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,OAAO;IACtB,kBAAkB,EAAE,aAAa;IACjC,oBAAoB,EAAE,eAAe;IACrC,YAAY,EAAE,cAAc;IAC5B,oBAAoB;IACpB,YAAY,EAAE,cAAc;CACpB,CAAC,CAAC;AAKZ,gBAAgB;AACH,QAAA,4BAA4B,GAAG,IAAI,GAAG,CAAgB;IACjE,qBAAa,CAAC,cAAc;IAC5B,qBAAa,CAAC,WAAW;IACzB,qBAAa,CAAC,YAAY;IAC1B,qBAAa,CAAC,YAAY;CAC3B,CAAC,CAAC"}