@mongosh/service-provider-core 2.2.15 → 2.3.1

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/AUTHORS CHANGED
@@ -17,3 +17,4 @@ Martin Rodriguez Reboredo <yakoyoku@gmail.com>
17
17
  Kevin Mas Ruiz <kevin.mas@hey.com>
18
18
  Hao <shaketbaby@gmail.com>
19
19
  Basit <1305718+mabaasit@users.noreply.github.com>
20
+ Alena Khineika <alena.khineika@mongodb.com>
package/lib/admin.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface CheckMetadataConsistencyOptions {
18
18
  }
19
19
  export interface ConnectionInfo {
20
20
  buildInfo: Document | null;
21
- topology: any | null;
21
+ resolvedHostname?: string;
22
22
  extraInfo: (ConnectionExtraInfo & {
23
23
  fcv?: string;
24
24
  }) | null;
@@ -1,9 +1,7 @@
1
- export interface ConnectionExtraInfo {
1
+ import type { ConnectionString } from 'mongodb-connection-string-url';
2
+ export type ConnectionExtraInfo = {
2
3
  is_atlas?: boolean;
3
- is_localhost?: boolean;
4
- is_do?: boolean;
5
4
  server_version?: string;
6
- mongosh_version?: string;
7
5
  server_os?: string;
8
6
  server_arch?: string;
9
7
  is_enterprise?: boolean;
@@ -17,5 +15,16 @@ export interface ConnectionExtraInfo {
17
15
  node_version?: string;
18
16
  uri: string;
19
17
  is_local_atlas?: boolean;
20
- }
21
- export default function getConnectExtraInfo(uri: string, mongoshVersion: string, buildInfo: any, atlasVersion: any, topology: any, isLocalAtlas: boolean): ConnectionExtraInfo;
18
+ } & HostInformation;
19
+ export type HostInformation = {
20
+ is_localhost?: boolean;
21
+ is_atlas_url?: boolean;
22
+ is_do_url?: boolean;
23
+ };
24
+ export default function getConnectExtraInfo({ connectionString, buildInfo, atlasVersion, resolvedHostname, isLocalAtlas, }: {
25
+ connectionString?: ConnectionString;
26
+ buildInfo: any;
27
+ atlasVersion: any;
28
+ resolvedHostname?: string;
29
+ isLocalAtlas: boolean;
30
+ }): ConnectionExtraInfo;
@@ -4,22 +4,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const mongodb_build_info_1 = __importDefault(require("mongodb-build-info"));
7
- function getConnectExtraInfo(uri, mongoshVersion, buildInfo, atlasVersion, topology, isLocalAtlas) {
8
- var _a;
7
+ function getHostInformation(host) {
8
+ if (!host) {
9
+ return {
10
+ is_localhost: false,
11
+ is_do_url: false,
12
+ is_atlas_url: false,
13
+ };
14
+ }
15
+ if (mongodb_build_info_1.default.isLocalhost(host)) {
16
+ return {
17
+ is_localhost: true,
18
+ is_do_url: false,
19
+ is_atlas_url: false,
20
+ };
21
+ }
22
+ if (mongodb_build_info_1.default.isDigitalOcean(host)) {
23
+ return {
24
+ is_localhost: false,
25
+ is_do_url: true,
26
+ is_atlas_url: false,
27
+ };
28
+ }
29
+ return {
30
+ is_localhost: false,
31
+ is_do_url: false,
32
+ is_atlas_url: mongodb_build_info_1.default.isAtlas(host),
33
+ };
34
+ }
35
+ function getConnectExtraInfo({ connectionString, buildInfo, atlasVersion, resolvedHostname, isLocalAtlas, }) {
36
+ var _a, _b, _c;
37
+ const auth_type = (_a = connectionString === null || connectionString === void 0 ? void 0 : connectionString.searchParams.get('authMechanism')) !== null && _a !== void 0 ? _a : undefined;
38
+ const uri = (_b = connectionString === null || connectionString === void 0 ? void 0 : connectionString.toString()) !== null && _b !== void 0 ? _b : '';
9
39
  buildInfo !== null && buildInfo !== void 0 ? buildInfo : (buildInfo = {});
10
40
  const { isGenuine: is_genuine, serverName: non_genuine_server_name } = mongodb_build_info_1.default.getGenuineMongoDB(uri);
11
41
  const { isDataLake: is_data_federation, dlVersion: dl_version } = mongodb_build_info_1.default.getDataLake(buildInfo);
12
- const auth_type = topology.s.credentials
13
- ? topology.s.credentials.mechanism
14
- : null;
15
42
  const { serverOs: server_os, serverArch: server_arch } = mongodb_build_info_1.default.getBuildEnv(buildInfo);
43
+ const isAtlas = !!(atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) || mongodb_build_info_1.default.isAtlas(uri);
16
44
  return {
17
- is_atlas: !!(atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) || mongodb_build_info_1.default.isAtlas(uri),
18
- is_localhost: mongodb_build_info_1.default.isLocalhost(uri),
19
- is_do: mongodb_build_info_1.default.isDigitalOcean(uri),
45
+ ...getHostInformation(resolvedHostname || uri),
46
+ is_atlas: isAtlas,
20
47
  server_version: buildInfo.version,
21
48
  node_version: process.version,
22
- mongosh_version: mongoshVersion,
23
49
  server_os,
24
50
  uri,
25
51
  server_arch,
@@ -28,7 +54,7 @@ function getConnectExtraInfo(uri, mongoshVersion, buildInfo, atlasVersion, topol
28
54
  is_data_federation,
29
55
  is_stream: mongodb_build_info_1.default.isAtlasStream(uri),
30
56
  dl_version,
31
- atlas_version: (_a = atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) !== null && _a !== void 0 ? _a : null,
57
+ atlas_version: (_c = atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) !== null && _c !== void 0 ? _c : null,
32
58
  is_genuine,
33
59
  non_genuine_server_name,
34
60
  is_local_atlas: isLocalAtlas,
@@ -1 +1 @@
1
- {"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAEA,4EAA8C;AAuB9C,SAAwB,mBAAmB,CACzC,GAAW,EACX,cAAsB,EACtB,SAAc,EACd,YAAiB,EACjB,QAAa,EACb,YAAqB;;IAErB,SAAS,aAAT,SAAS,cAAT,SAAS,IAAT,SAAS,GAAK,EAAE,EAAC;IACjB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE,GAClE,4BAAY,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAEtC,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,SAAS,E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AE,UAAU,EAAE,WAAW,EAAE,GACpD,4BAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,CAAC,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,CAAA,IAAI,4BAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1E,OAAO;QACL,GAAG,kBAAkB,CAAC,gBAAgB,IAAI,GAAG,CAAC;QAC9C,QAAQ,EAAE,OAAO;QACjB,cAAc,EAAE,SAAS,CAAC,OAAO;QACjC,YAAY,EAAE,OAAO,CAAC,OAAO;QAC7B,SAAS;QACT,GAAG;QACH,WAAW;QACX,aAAa,EAAE,4BAAY,CAAC,YAAY,CAAC,SAAS,CAAC;QACnD,SAAS;QACT,kBAAkB;QAClB,SAAS,EAAE,4BAAY,CAAC,aAAa,CAAC,GAAG,CAAC;QAC1C,UAAU;QACV,aAAa,EAAE,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,mCAAI,IAAI;QACjD,UAAU;QACV,uBAAuB;QACvB,cAAc,EAAE,YAAY;KAC7B,CAAC;AACJ,CAAC;AA9CD,sCA8CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/service-provider-core",
3
- "version": "2.2.15",
3
+ "version": "2.3.1",
4
4
  "description": "MongoDB Shell Core Service Provider Package",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -44,22 +44,23 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@aws-sdk/credential-providers": "^3.525.0",
47
- "@mongosh/errors": "2.2.15",
47
+ "@mongosh/errors": "2.3.1",
48
48
  "bson": "^6.7.0",
49
49
  "mongodb": "^6.8.0",
50
50
  "mongodb-build-info": "^1.7.2",
51
- "mongodb-client-encryption": "^6.0.0"
51
+ "mongodb-client-encryption": "^6.1.0",
52
+ "mongodb-connection-string-url": "^3.0.1"
52
53
  },
53
54
  "optionalDependencies": {
54
- "mongodb-client-encryption": "^6.0.0"
55
+ "mongodb-client-encryption": "^6.1.0"
55
56
  },
56
57
  "devDependencies": {
57
- "@mongodb-js/eslint-config-mongosh": "2.2.15",
58
+ "@mongodb-js/eslint-config-mongosh": "2.3.1",
58
59
  "@mongodb-js/prettier-config-devtools": "^1.0.1",
59
- "@mongodb-js/tsconfig-mongosh": "2.2.15",
60
+ "@mongodb-js/tsconfig-mongosh": "2.3.1",
60
61
  "depcheck": "^1.4.3",
61
62
  "eslint": "^7.25.0",
62
63
  "prettier": "^2.8.8"
63
64
  },
64
- "gitHead": "1570f12d8dcdbf4668e2323edc124fd9c467e9f5"
65
+ "gitHead": "57a904a1acb7821eee4e4cde98ff779b87c612b1"
65
66
  }
package/src/admin.ts CHANGED
@@ -45,7 +45,7 @@ export interface CheckMetadataConsistencyOptions {
45
45
 
46
46
  export interface ConnectionInfo {
47
47
  buildInfo: Document | null;
48
- topology: any | null;
48
+ resolvedHostname?: string;
49
49
  extraInfo: (ConnectionExtraInfo & { fcv?: string }) | null;
50
50
  }
51
51
 
@@ -1,5 +1,6 @@
1
1
  import { expect } from 'chai';
2
- import getConnectInfo from './connect-info';
2
+ import getConnectExtraInfo from './connect-info';
3
+ import { ConnectionString } from 'mongodb-connection-string-url';
3
4
 
4
5
  describe('getConnectInfo', function () {
5
6
  const BUILD_INFO = {
@@ -46,30 +47,21 @@ describe('getConnectInfo', function () {
46
47
  gitVersion: '8f7e5bdde713391e8123a463895bb7fb660a5ffd',
47
48
  };
48
49
 
49
- const TOPOLOGY_WITH_CREDENTIALS = {
50
- s: {
51
- credentials: {
52
- mechanism: 'LDAP',
53
- },
54
- },
55
- };
56
-
57
- const TOPOLOGY_NO_CREDENTIALS = {
58
- s: {},
59
- };
60
-
61
50
  const ATLAS_URI =
62
- 'mongodb+srv://admin:catscatscats@cat-data-sets.cats.example.net/admin';
51
+ 'mongodb+srv://admin:catscatscats@cat-data-sets.cats.mongodb.net/admin';
52
+
53
+ const ATLAS_URI_WITH_AUTH =
54
+ 'mongodb+srv://admin:catscatscats@cat-data-sets.cats.mongodb.net/admin?authMechanism=PLAIN&authSource=%24external';
63
55
 
64
56
  it('reports on an enterprise version >=3.2 of mongodb with credentials', function () {
65
57
  const output = {
66
58
  is_atlas: true,
59
+ is_atlas_url: true,
67
60
  is_localhost: false,
68
- is_do: false,
61
+ is_do_url: false,
69
62
  server_version: '3.2.0-rc2',
70
- mongosh_version: '0.0.6',
71
63
  is_enterprise: true,
72
- auth_type: 'LDAP',
64
+ auth_type: 'PLAIN',
73
65
  is_data_federation: false,
74
66
  is_stream: false,
75
67
  dl_version: null,
@@ -79,30 +71,29 @@ describe('getConnectInfo', function () {
79
71
  server_arch: 'x86_64',
80
72
  node_version: process.version,
81
73
  server_os: 'osx',
82
- uri: ATLAS_URI,
74
+ uri: ATLAS_URI_WITH_AUTH,
83
75
  is_local_atlas: false,
84
76
  };
85
77
  expect(
86
- getConnectInfo(
87
- ATLAS_URI,
88
- '0.0.6',
89
- BUILD_INFO,
90
- ATLAS_VERSION,
91
- TOPOLOGY_WITH_CREDENTIALS,
92
- false
93
- )
78
+ getConnectExtraInfo({
79
+ connectionString: new ConnectionString(ATLAS_URI_WITH_AUTH),
80
+ buildInfo: BUILD_INFO,
81
+ atlasVersion: ATLAS_VERSION,
82
+ resolvedHostname: 'test-data-sets-00-02-a011bb.mongodb.net',
83
+ isLocalAtlas: false,
84
+ })
94
85
  ).to.deep.equal(output);
95
86
  });
96
87
 
97
88
  it('reports on an enterprise version >=3.2 of mongodb with no credentials', function () {
98
89
  const output = {
99
90
  is_atlas: true,
91
+ is_atlas_url: true,
100
92
  is_localhost: false,
101
- is_do: false,
93
+ is_do_url: false,
102
94
  server_version: '3.2.0-rc2',
103
- mongosh_version: '0.0.6',
104
95
  is_enterprise: true,
105
- auth_type: null,
96
+ auth_type: undefined,
106
97
  is_data_federation: false,
107
98
  is_stream: false,
108
99
  dl_version: null,
@@ -116,14 +107,13 @@ describe('getConnectInfo', function () {
116
107
  is_local_atlas: false,
117
108
  };
118
109
  expect(
119
- getConnectInfo(
120
- ATLAS_URI,
121
- '0.0.6',
122
- BUILD_INFO,
123
- ATLAS_VERSION,
124
- TOPOLOGY_NO_CREDENTIALS,
125
- false
126
- )
110
+ getConnectExtraInfo({
111
+ connectionString: new ConnectionString(ATLAS_URI),
112
+ buildInfo: BUILD_INFO,
113
+ atlasVersion: ATLAS_VERSION,
114
+ resolvedHostname: 'test-data-sets-00-02-a011bb.mongodb.net',
115
+ isLocalAtlas: false,
116
+ })
127
117
  ).to.deep.equal(output);
128
118
  });
129
119
 
@@ -132,12 +122,12 @@ describe('getConnectInfo', function () {
132
122
  'mongodb://atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net/';
133
123
  const output = {
134
124
  is_atlas: true,
125
+ is_atlas_url: true,
135
126
  is_localhost: false,
136
- is_do: false,
127
+ is_do_url: false,
137
128
  server_version: '3.2.0-rc2',
138
- mongosh_version: '0.0.6',
139
129
  is_enterprise: true,
140
- auth_type: 'LDAP',
130
+ auth_type: undefined,
141
131
  is_data_federation: false,
142
132
  is_stream: true,
143
133
  dl_version: null,
@@ -151,26 +141,26 @@ describe('getConnectInfo', function () {
151
141
  uri: streamUri,
152
142
  };
153
143
  expect(
154
- getConnectInfo(
155
- streamUri,
156
- '0.0.6',
157
- BUILD_INFO,
158
- null,
159
- TOPOLOGY_WITH_CREDENTIALS,
160
- false
161
- )
144
+ getConnectExtraInfo({
145
+ connectionString: new ConnectionString(streamUri),
146
+ buildInfo: BUILD_INFO,
147
+ atlasVersion: null,
148
+ resolvedHostname:
149
+ 'atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net',
150
+ isLocalAtlas: false,
151
+ })
162
152
  ).to.deep.equal(output);
163
153
  });
164
154
 
165
155
  it('reports correct information when an empty uri is passed', function () {
166
156
  const output = {
167
157
  is_atlas: false,
168
- is_localhost: false,
169
- is_do: false,
158
+ is_atlas_url: false,
159
+ is_localhost: true,
160
+ is_do_url: false,
170
161
  server_version: '3.2.0-rc2',
171
- mongosh_version: '0.0.6',
172
162
  is_enterprise: true,
173
- auth_type: 'LDAP',
163
+ auth_type: undefined,
174
164
  is_data_federation: false,
175
165
  is_stream: false,
176
166
  dl_version: null,
@@ -184,26 +174,24 @@ describe('getConnectInfo', function () {
184
174
  is_local_atlas: true,
185
175
  };
186
176
  expect(
187
- getConnectInfo(
188
- '',
189
- '0.0.6',
190
- BUILD_INFO,
191
- null,
192
- TOPOLOGY_WITH_CREDENTIALS,
193
- true
194
- )
177
+ getConnectExtraInfo({
178
+ buildInfo: BUILD_INFO,
179
+ atlasVersion: null,
180
+ resolvedHostname: 'localhost',
181
+ isLocalAtlas: true,
182
+ })
195
183
  ).to.deep.equal(output);
196
184
  });
197
185
 
198
186
  it('does not fail when buildInfo is unavailable', function () {
199
187
  const output = {
200
188
  is_atlas: false,
189
+ is_atlas_url: false,
201
190
  is_localhost: false,
202
- is_do: false,
191
+ is_do_url: false,
203
192
  server_version: undefined,
204
- mongosh_version: '0.0.6',
205
193
  is_enterprise: false,
206
- auth_type: 'LDAP',
194
+ auth_type: undefined,
207
195
  is_data_federation: false,
208
196
  is_stream: false,
209
197
  dl_version: null,
@@ -217,7 +205,11 @@ describe('getConnectInfo', function () {
217
205
  is_local_atlas: false,
218
206
  };
219
207
  expect(
220
- getConnectInfo('', '0.0.6', null, null, TOPOLOGY_WITH_CREDENTIALS, false)
208
+ getConnectExtraInfo({
209
+ buildInfo: null,
210
+ atlasVersion: null,
211
+ isLocalAtlas: false,
212
+ })
221
213
  ).to.deep.equal(output);
222
214
  });
223
215
  });
@@ -1,13 +1,11 @@
1
1
  // ^ segment data is in snake_case: forgive me javascript, for i have sinned.
2
2
 
3
3
  import getBuildInfo from 'mongodb-build-info';
4
+ import type { ConnectionString } from 'mongodb-connection-string-url';
4
5
 
5
- export interface ConnectionExtraInfo {
6
+ export type ConnectionExtraInfo = {
6
7
  is_atlas?: boolean;
7
- is_localhost?: boolean;
8
- is_do?: boolean;
9
8
  server_version?: string;
10
- mongosh_version?: string;
11
9
  server_os?: string;
12
10
  server_arch?: string;
13
11
  is_enterprise?: boolean;
@@ -21,16 +19,63 @@ export interface ConnectionExtraInfo {
21
19
  node_version?: string;
22
20
  uri: string;
23
21
  is_local_atlas?: boolean;
22
+ } & HostInformation;
23
+
24
+ export type HostInformation = {
25
+ is_localhost?: boolean;
26
+ is_atlas_url?: boolean;
27
+ is_do_url?: boolean; // Is digital ocean url.
28
+ };
29
+
30
+ function getHostInformation(host?: string): HostInformation {
31
+ if (!host) {
32
+ return {
33
+ is_localhost: false,
34
+ is_do_url: false,
35
+ is_atlas_url: false,
36
+ };
37
+ }
38
+
39
+ if (getBuildInfo.isLocalhost(host)) {
40
+ return {
41
+ is_localhost: true,
42
+ is_do_url: false,
43
+ is_atlas_url: false,
44
+ };
45
+ }
46
+
47
+ if (getBuildInfo.isDigitalOcean(host)) {
48
+ return {
49
+ is_localhost: false,
50
+ is_do_url: true,
51
+ is_atlas_url: false,
52
+ };
53
+ }
54
+
55
+ return {
56
+ is_localhost: false,
57
+ is_do_url: false,
58
+ is_atlas_url: getBuildInfo.isAtlas(host),
59
+ };
24
60
  }
25
61
 
26
- export default function getConnectExtraInfo(
27
- uri: string,
28
- mongoshVersion: string,
29
- buildInfo: any,
30
- atlasVersion: any,
31
- topology: any,
32
- isLocalAtlas: boolean
33
- ): ConnectionExtraInfo {
62
+ export default function getConnectExtraInfo({
63
+ connectionString,
64
+ buildInfo,
65
+ atlasVersion,
66
+ resolvedHostname,
67
+ isLocalAtlas,
68
+ }: {
69
+ connectionString?: ConnectionString;
70
+ buildInfo: any;
71
+ atlasVersion: any;
72
+ resolvedHostname?: string;
73
+ isLocalAtlas: boolean;
74
+ }): ConnectionExtraInfo {
75
+ const auth_type =
76
+ connectionString?.searchParams.get('authMechanism') ?? undefined;
77
+ const uri = connectionString?.toString() ?? '';
78
+
34
79
  buildInfo ??= {}; // We're currently not getting buildInfo with --apiStrict.
35
80
  const { isGenuine: is_genuine, serverName: non_genuine_server_name } =
36
81
  getBuildInfo.getGenuineMongoDB(uri);
@@ -38,19 +83,15 @@ export default function getConnectExtraInfo(
38
83
  const { isDataLake: is_data_federation, dlVersion: dl_version } =
39
84
  getBuildInfo.getDataLake(buildInfo);
40
85
 
41
- const auth_type = topology.s.credentials
42
- ? topology.s.credentials.mechanism
43
- : null;
44
86
  const { serverOs: server_os, serverArch: server_arch } =
45
87
  getBuildInfo.getBuildEnv(buildInfo);
88
+ const isAtlas = !!atlasVersion?.atlasVersion || getBuildInfo.isAtlas(uri);
46
89
 
47
90
  return {
48
- is_atlas: !!atlasVersion?.atlasVersion || getBuildInfo.isAtlas(uri),
49
- is_localhost: getBuildInfo.isLocalhost(uri),
50
- is_do: getBuildInfo.isDigitalOcean(uri),
91
+ ...getHostInformation(resolvedHostname || uri),
92
+ is_atlas: isAtlas,
51
93
  server_version: buildInfo.version,
52
94
  node_version: process.version,
53
- mongosh_version: mongoshVersion,
54
95
  server_os,
55
96
  uri,
56
97
  server_arch,