@mongosh/service-provider-core 2.2.15 → 2.3.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.
- package/AUTHORS +1 -0
- package/lib/admin.d.ts +1 -1
- package/lib/connect-info.d.ts +15 -6
- package/lib/connect-info.js +36 -10
- package/lib/connect-info.js.map +1 -1
- package/package.json +8 -7
- package/src/admin.ts +1 -1
- package/src/connect-info.spec.ts +56 -64
- package/src/connect-info.ts +60 -19
package/AUTHORS
CHANGED
package/lib/admin.d.ts
CHANGED
package/lib/connect-info.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
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
|
|
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;
|
package/lib/connect-info.js
CHANGED
|
@@ -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
|
|
8
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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: (
|
|
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,
|
package/lib/connect-info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAEA,4EAA8C;
|
|
1
|
+
{"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAEA,4EAA8C;AA2B9C,SAAS,kBAAkB,CAAC,IAAa;IACvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC;IACJ,CAAC;IAED,IAAI,4BAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO;YACL,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC;IACJ,CAAC;IAED,IAAI,4BAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,KAAK;SACpB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,4BAAY,CAAC,OAAO,CAAC,IAAI,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,SAAwB,mBAAmB,CAAC,EAC1C,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,GAOb;;IACC,MAAM,SAAS,GACb,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,mCAAI,SAAS,CAAC;IACnE,MAAM,GAAG,GAAG,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,EAAE,mCAAI,EAAE,CAAC;IAE/C,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,EAAE,UAAU,EAAE,GAC7D,4BAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAEtC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,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.
|
|
3
|
+
"version": "2.3.0",
|
|
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.
|
|
47
|
+
"@mongosh/errors": "2.3.0",
|
|
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.
|
|
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.
|
|
55
|
+
"mongodb-client-encryption": "^6.1.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@mongodb-js/eslint-config-mongosh": "2.
|
|
58
|
+
"@mongodb-js/eslint-config-mongosh": "2.3.0",
|
|
58
59
|
"@mongodb-js/prettier-config-devtools": "^1.0.1",
|
|
59
|
-
"@mongodb-js/tsconfig-mongosh": "2.
|
|
60
|
+
"@mongodb-js/tsconfig-mongosh": "2.3.0",
|
|
60
61
|
"depcheck": "^1.4.3",
|
|
61
62
|
"eslint": "^7.25.0",
|
|
62
63
|
"prettier": "^2.8.8"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2013159f06f902b4e9a2060df411c6b5646d49d4"
|
|
65
66
|
}
|
package/src/admin.ts
CHANGED
package/src/connect-info.spec.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import
|
|
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.
|
|
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
|
-
|
|
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: '
|
|
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:
|
|
74
|
+
uri: ATLAS_URI_WITH_AUTH,
|
|
83
75
|
is_local_atlas: false,
|
|
84
76
|
};
|
|
85
77
|
expect(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
120
|
-
ATLAS_URI,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
155
|
-
streamUri,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
169
|
-
|
|
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:
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
191
|
+
is_do_url: false,
|
|
203
192
|
server_version: undefined,
|
|
204
|
-
mongosh_version: '0.0.6',
|
|
205
193
|
is_enterprise: false,
|
|
206
|
-
auth_type:
|
|
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
|
-
|
|
208
|
+
getConnectExtraInfo({
|
|
209
|
+
buildInfo: null,
|
|
210
|
+
atlasVersion: null,
|
|
211
|
+
isLocalAtlas: false,
|
|
212
|
+
})
|
|
221
213
|
).to.deep.equal(output);
|
|
222
214
|
});
|
|
223
215
|
});
|
package/src/connect-info.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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,
|