@mongodb-js/connection-form 1.87.2 → 1.89.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/dist/components/advanced-connection-options.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/advanced-options-tabs.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/advanced-options-tabs.js +3 -3
- package/dist/components/advanced-options-tabs/advanced-tab/advanced-tab.d.ts +1 -7
- package/dist/components/advanced-options-tabs/advanced-tab/advanced-tab.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/advanced-tab/advanced-tab.js +3 -37
- package/dist/components/advanced-options-tabs/advanced-tab/read-preference-form.d.ts +17 -0
- package/dist/components/advanced-options-tabs/advanced-tab/read-preference-form.d.ts.map +1 -0
- package/dist/components/advanced-options-tabs/advanced-tab/read-preference-form.js +148 -0
- package/dist/components/advanced-options-tabs/advanced-tab/url-options-list-editor.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/advanced-tab/url-options-list-editor.js +2 -1
- package/dist/components/advanced-options-tabs/authentication-tab/authentication-tab.js +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/csfle-tab.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/csfle-tab.js +3 -3
- package/dist/components/advanced-options-tabs/csfle-tab/encrypted-field-config-input.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/encrypted-field-config-input.js +4 -2
- package/dist/components/advanced-options-tabs/csfle-tab/kms-local-key-generator.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-card.d.ts +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-card.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-content.d.ts +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-content.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-fields.d.ts +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-fields.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/csfle-tab/kms-provider-status-indicator.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/general-tab/general-tab.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/general-tab/host-input.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/general-tab/host-input.js +1 -1
- package/dist/components/advanced-options-tabs/ssh-tunnel-tab/proxy-and-ssh-tunnel-tab.d.ts.map +1 -1
- package/dist/components/advanced-options-tabs/ssh-tunnel-tab/proxy-and-ssh-tunnel-tab.js +1 -1
- package/dist/components/advanced-options-tabs/tls-ssl-tab/tls-ssl-tab.d.ts.map +1 -1
- package/dist/components/connection-form.d.ts.map +1 -1
- package/dist/components/connection-form.js +64 -35
- package/dist/hooks/use-connect-form.d.ts +3 -2
- package/dist/hooks/use-connect-form.d.ts.map +1 -1
- package/dist/hooks/use-connect-form.js +15 -5
- package/dist/utils/authentication-handler.d.ts.map +1 -1
- package/dist/utils/authentication-handler.js +1 -1
- package/dist/utils/connection-ssh-handler.d.ts.map +1 -1
- package/dist/utils/csfle-handler.d.ts +3 -2
- package/dist/utils/csfle-handler.d.ts.map +1 -1
- package/dist/utils/csfle-handler.js +14 -7
- package/dist/utils/csfle-kms-fields.d.ts.map +1 -1
- package/dist/utils/read-preference-handler.d.ts +18 -0
- package/dist/utils/read-preference-handler.d.ts.map +1 -0
- package/dist/utils/read-preference-handler.js +37 -0
- package/dist/utils/url-options.d.ts.map +1 -1
- package/dist/utils/url-options.js +0 -4
- package/dist/utils/validation.d.ts +4 -2
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +53 -7
- package/package.json +13 -14
package/dist/utils/validation.js
CHANGED
|
@@ -10,9 +10,10 @@ exports.errorMessageByFieldNameAndIndex = errorMessageByFieldNameAndIndex;
|
|
|
10
10
|
exports.validateConnectionOptionsErrors = validateConnectionOptionsErrors;
|
|
11
11
|
exports.isSecure = isSecure;
|
|
12
12
|
exports.validateConnectionOptionsWarnings = validateConnectionOptionsWarnings;
|
|
13
|
-
const mongodb_build_info_1 = require("mongodb-build-info");
|
|
13
|
+
const mongodb_build_info_1 = require("@mongodb-js/mongodb-build-info");
|
|
14
14
|
const mongodb_connection_string_url_1 = __importDefault(require("mongodb-connection-string-url"));
|
|
15
15
|
const csfle_handler_1 = require("../utils/csfle-handler");
|
|
16
|
+
const read_preference_handler_1 = require("./read-preference-handler");
|
|
16
17
|
function errorsByFieldTab(errors, tabId) {
|
|
17
18
|
return errors.filter((error) => error.fieldTab === tabId);
|
|
18
19
|
}
|
|
@@ -25,17 +26,60 @@ function fieldNameHasError(errors, fieldName) {
|
|
|
25
26
|
function errorMessageByFieldNameAndIndex(errors, fieldName, fieldIndex) {
|
|
26
27
|
return (errors || []).find((err) => err.fieldName === fieldName && err.fieldIndex === fieldIndex)?.message;
|
|
27
28
|
}
|
|
28
|
-
function validateConnectionOptionsErrors(connectionOptions, parsingOptions) {
|
|
29
|
+
function validateConnectionOptionsErrors(connectionOptions, parsingOptions, { isAtlas = false } = {}) {
|
|
29
30
|
const connectionString = new mongodb_connection_string_url_1.default(connectionOptions.connectionString, { looseValidation: true, ...parsingOptions });
|
|
30
31
|
return [
|
|
31
|
-
...validateAuthMechanismErrors(connectionString),
|
|
32
|
+
...validateAuthMechanismErrors(connectionString, { isAtlas }),
|
|
32
33
|
...validateCSFLEErrors(connectionOptions.fleOptions?.autoEncryption ?? {}),
|
|
33
34
|
...(connectionOptions.sshTunnel
|
|
34
35
|
? validateSSHTunnelErrors(connectionOptions.sshTunnel)
|
|
35
36
|
: validateSocksProxyErrors(connectionString)),
|
|
37
|
+
...validateReadPreferenceErrors(connectionString),
|
|
36
38
|
];
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// https://www.mongodb.com/docs/manual/core/read-preference-staleness/
|
|
41
|
+
const MIN_MAX_STALENESS_SECONDS = 90;
|
|
42
|
+
const TAG_SET_PATTERN = /^[^:,]+:[^:,]*(,[^:,]+:[^:,]*)*$/;
|
|
43
|
+
function validateReadPreferenceErrors(connectionString) {
|
|
44
|
+
const searchParams = connectionString.typedSearchParams();
|
|
45
|
+
const mode = searchParams.get('readPreference');
|
|
46
|
+
const tagSets = searchParams.getAll('readPreferenceTags');
|
|
47
|
+
const maxStalenessSeconds = searchParams.get('maxStalenessSeconds');
|
|
48
|
+
if (!(0, read_preference_handler_1.supportsReadPreferenceOptions)(mode)) {
|
|
49
|
+
return tagSets.length > 0 || maxStalenessSeconds
|
|
50
|
+
? [
|
|
51
|
+
{
|
|
52
|
+
message: 'Read preference tags and max staleness can only be used with a read preference other than primary.',
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
: [];
|
|
56
|
+
}
|
|
57
|
+
const errors = [];
|
|
58
|
+
tagSets.forEach((tagSet, index) => {
|
|
59
|
+
if (tagSet !== '' && !TAG_SET_PATTERN.test(tagSet)) {
|
|
60
|
+
errors.push({
|
|
61
|
+
fieldTab: 'advanced',
|
|
62
|
+
fieldName: 'readPreferenceTags',
|
|
63
|
+
fieldIndex: index,
|
|
64
|
+
message: 'Tag sets must be in the format key0:value0,key1:value1.',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (maxStalenessSeconds) {
|
|
69
|
+
const value = Number(maxStalenessSeconds);
|
|
70
|
+
// -1 is the driver's way of explicitly saying "no maximum".
|
|
71
|
+
if (!Number.isInteger(value) ||
|
|
72
|
+
(value !== -1 && value < MIN_MAX_STALENESS_SECONDS)) {
|
|
73
|
+
errors.push({
|
|
74
|
+
fieldTab: 'advanced',
|
|
75
|
+
fieldName: 'maxStalenessSeconds',
|
|
76
|
+
message: `Max staleness must be at least ${MIN_MAX_STALENESS_SECONDS} seconds.`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return errors;
|
|
81
|
+
}
|
|
82
|
+
function validateAuthMechanismErrors(connectionString, { isAtlas }) {
|
|
39
83
|
const authMechanism = connectionString
|
|
40
84
|
.typedSearchParams()
|
|
41
85
|
.get('authMechanism');
|
|
@@ -43,7 +87,7 @@ function validateAuthMechanismErrors(connectionString) {
|
|
|
43
87
|
case '':
|
|
44
88
|
return validateDefaultAuthMechanismErrors(connectionString);
|
|
45
89
|
case 'MONGODB-X509':
|
|
46
|
-
return validateX509Errors(connectionString);
|
|
90
|
+
return validateX509Errors(connectionString, { isAtlas });
|
|
47
91
|
case 'GSSAPI':
|
|
48
92
|
return validateKerberosErrors(connectionString);
|
|
49
93
|
case 'PLAIN':
|
|
@@ -84,7 +128,7 @@ function validateUsernameAndPasswordErrors(connectionString) {
|
|
|
84
128
|
}
|
|
85
129
|
return errors;
|
|
86
130
|
}
|
|
87
|
-
function validateX509Errors(connectionString) {
|
|
131
|
+
function validateX509Errors(connectionString, { isAtlas }) {
|
|
88
132
|
const errors = [];
|
|
89
133
|
if (!isSecure(connectionString)) {
|
|
90
134
|
errors.push({
|
|
@@ -93,7 +137,9 @@ function validateX509Errors(connectionString) {
|
|
|
93
137
|
message: 'TLS must be enabled in order to use x509 authentication.',
|
|
94
138
|
});
|
|
95
139
|
}
|
|
96
|
-
|
|
140
|
+
// Connection info from Atlas always uses X.509 but never includes a
|
|
141
|
+
// certificate, so requiring one would block every Data Explorer connection.
|
|
142
|
+
if (!isAtlas && !connectionString.searchParams.has('tlsCertificateKeyFile')) {
|
|
97
143
|
errors.push({
|
|
98
144
|
fieldTab: 'tls',
|
|
99
145
|
fieldName: 'tlsCertificateKeyFile',
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"email": "compass@mongodb.com"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/mongodb-js/compass",
|
|
16
|
-
"version": "1.
|
|
16
|
+
"version": "1.89.0",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "https://github.com/mongodb-js/compass.git"
|
|
@@ -48,24 +48,23 @@
|
|
|
48
48
|
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@mongodb-js/compass-components": "^1.
|
|
52
|
-
"@mongodb-js/compass-editor": "^0.
|
|
53
|
-
"@mongodb-js/connection-info": "^0.29.
|
|
54
|
-
"@mongodb-js/
|
|
51
|
+
"@mongodb-js/compass-components": "^1.71.0",
|
|
52
|
+
"@mongodb-js/compass-editor": "^0.73.0",
|
|
53
|
+
"@mongodb-js/connection-info": "^0.29.5",
|
|
54
|
+
"@mongodb-js/mongodb-build-info": "^1.9.19",
|
|
55
|
+
"@mongodb-js/shell-bson-parser": "^2.0.0",
|
|
55
56
|
"lodash": "^4.18.1",
|
|
56
57
|
"mongodb": "^7.5.0",
|
|
57
|
-
"mongodb-build-info": "^1.8.1",
|
|
58
58
|
"mongodb-connection-string-url": "^7.0.2",
|
|
59
|
-
"mongodb-data-service": "^22.41.
|
|
60
|
-
"mongodb-query-parser": "^5.1.3",
|
|
59
|
+
"mongodb-data-service": "^22.41.5",
|
|
61
60
|
"react": "^18.3.1"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@mongodb-js/eslint-config-compass": "^1.4.
|
|
65
|
-
"@mongodb-js/mocha-config-compass": "^1.
|
|
66
|
-
"@mongodb-js/prettier-config-compass": "^1.2.
|
|
67
|
-
"@mongodb-js/testing-library-compass": "^1.7.
|
|
68
|
-
"@mongodb-js/tsconfig-compass": "^1.3.
|
|
63
|
+
"@mongodb-js/eslint-config-compass": "^1.4.31",
|
|
64
|
+
"@mongodb-js/mocha-config-compass": "^1.9.0",
|
|
65
|
+
"@mongodb-js/prettier-config-compass": "^1.2.10",
|
|
66
|
+
"@mongodb-js/testing-library-compass": "^1.7.5",
|
|
67
|
+
"@mongodb-js/tsconfig-compass": "^1.3.2",
|
|
69
68
|
"@types/chai": "^4.2.21",
|
|
70
69
|
"@types/chai-dom": "^0.0.10",
|
|
71
70
|
"@types/mocha": "^9.0.0",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"sinon": "^9.2.3",
|
|
81
80
|
"xvfb-maybe": "^0.2.1"
|
|
82
81
|
},
|
|
83
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "ffed0669174748402f0d54164e9aaed0949eb888"
|
|
84
83
|
}
|