From 43d6fa45f4ad85cc4bc7691fc1a426ca95245bff Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 15 Jun 2021 21:55:51 +0200 Subject: [PATCH] chore: move ConnectionString into separate package MONGOSH-829 --- .../service-provider-core/package-lock.json | 24 +-- packages/service-provider-core/package.json | 5 +- .../src/connection-string.spec.ts | 168 ------------------ .../src/connection-string.ts | 152 ---------------- packages/service-provider-core/src/index.ts | 3 +- ...l.spec.ts => textencoder-polyfill.spec.ts} | 2 +- .../src/textencoder-polyfill.ts | 28 +++ .../src/uri-generator.ts | 2 +- .../service-provider-core/src/whatwg-url.ts | 57 ------ .../service-provider-server/package-lock.json | 19 +- packages/service-provider-server/package.json | 3 +- .../cli-service-provider.integration.spec.ts | 3 +- .../src/cli-service-provider.spec.ts | 2 +- .../src/cli-service-provider.ts | 2 +- .../src/compass/compass-service-provider.ts | 3 +- 15 files changed, 60 insertions(+), 413 deletions(-) delete mode 100644 packages/service-provider-core/src/connection-string.spec.ts delete mode 100644 packages/service-provider-core/src/connection-string.ts rename packages/service-provider-core/src/{whatwg-url.spec.ts => textencoder-polyfill.spec.ts} (85%) create mode 100644 packages/service-provider-core/src/textencoder-polyfill.ts delete mode 100644 packages/service-provider-core/src/whatwg-url.ts diff --git a/packages/service-provider-core/package-lock.json b/packages/service-provider-core/package-lock.json index 687828ae58..876f23ed97 100644 --- a/packages/service-provider-core/package-lock.json +++ b/packages/service-provider-core/package-lock.json @@ -19,22 +19,6 @@ "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==", "dev": true }, - "@types/webidl-conversions": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.0.tgz", - "integrity": "sha512-SI9Jyayf2Ia28QFm0Mb3rVcA7ZwU89sos+gQQ6oY4/eKAReHyYYWTZD8Oqsq+CIRfZ+rEskvBaTZzHJ9njGZZQ==", - "dev": true - }, - "@types/whatwg-url": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.0.0.tgz", - "integrity": "sha512-vEjjqMjljhnkrNPD7wQBu20iStszRJggZ1E3qMRf0f4YkDOdRTu/wQkOQTG8gdJJs3SNLtiQTL1E6zknxsoWOg==", - "dev": true, - "requires": { - "@types/node": "*", - "@types/webidl-conversions": "*" - } - }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -297,6 +281,14 @@ "prebuild-install": "6.1.2" } }, + "mongodb-connection-string-url": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-1.0.0.tgz", + "integrity": "sha512-s2kSyqM/PgvLHKzc67eK/syC4n2eXu4Q2XWA4gJOgMvOk1/bsZ8jW04EBFabfNHgw66gYSovx9F623eKEkpfGA==", + "requires": { + "whatwg-url": "^8.4.0" + } + }, "nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", diff --git a/packages/service-provider-core/package.json b/packages/service-provider-core/package.json index 45d971455f..54d99b8a6a 100644 --- a/packages/service-provider-core/package.json +++ b/packages/service-provider-core/package.json @@ -32,11 +32,10 @@ "bson": "^4.4.0", "mongodb": "4.0.0-beta.5", "mongodb-build-info": "^1.1.1", - "whatwg-url": "^8.4.0" + "mongodb-connection-string-url": "^1.0.0" }, "devDependencies": { - "@types/bl": "^2.1.0", - "@types/whatwg-url": "^8.0.0" + "@types/bl": "^2.1.0" }, "optionalDependencies": { "mongodb-client-encryption": "^1.2.5" diff --git a/packages/service-provider-core/src/connection-string.spec.ts b/packages/service-provider-core/src/connection-string.spec.ts deleted file mode 100644 index 3c41e095af..0000000000 --- a/packages/service-provider-core/src/connection-string.spec.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { expect } from 'chai'; -import { ConnectionString } from './connection-string'; - -describe('ConnectionString', () => { - context('with valid URIs', () => { - for (const { uri, match } of [ - { - uri: 'mongodb://localhost/', - match: { - href: 'mongodb://localhost/', - protocol: 'mongodb:', - username: '', - password: '', - pathname: '/', - search: '', - hash: '', - isSRV: false, - hosts: ['localhost'] - } - }, - { - uri: 'mongodb+srv://localhost', - match: { - href: 'mongodb+srv://localhost/', - protocol: 'mongodb+srv:', - username: '', - password: '', - pathname: '/', - search: '', - hash: '', - isSRV: true, - hosts: ['localhost'] - } - }, - { - uri: 'mongodb+srv://cat:meow@localhost/', - match: { - href: 'mongodb+srv://cat:meow@localhost/', - protocol: 'mongodb+srv:', - username: 'cat', - password: 'meow', - pathname: '/', - search: '', - hash: '', - isSRV: true, - hosts: ['localhost'] - } - }, - { - uri: 'mongodb://cat:meow@localhost:12345/db', - match: { - href: 'mongodb://cat:meow@localhost:12345/db', - protocol: 'mongodb:', - username: 'cat', - password: 'meow', - pathname: '/db', - search: '', - hash: '', - isSRV: false, - hosts: ['localhost:12345'] - } - }, - { - uri: 'mongodb://localhost:12345,anotherHost/?directConnection=true', - match: { - href: 'mongodb://localhost:12345,anotherHost/?directConnection=true', - protocol: 'mongodb:', - username: '', - password: '', - pathname: '/', - search: '?directConnection=true', - hash: '', - isSRV: false, - hosts: ['localhost:12345', 'anotherHost'] - } - } - ]) { - it(`parses ${uri} correctly`, () => { - const cs = new ConnectionString(uri); - for (const key of Object.keys(match) as (keyof typeof cs & keyof typeof match)[]) { - expect(cs[key]).to.deep.equal(match[key]); - } - }); - } - }); - - context('with invalid URIs', () => { - for (const uri of [ - '', - '//', - '//@/', - 'mongodb://', - 'mongodb://@localhost/', - 'mongodb://:@localhost/', - 'mongodb://:pass@localhost/', - 'mongodb://%a@localhost/', - 'mongodb://:%a@localhost/', - 'mongodb://a[@localhost/', - 'mongodb://a:[@localhost/', - 'mongodb+srv://a,b,c/', - 'mongodb+srv://a:12345/' - ]) { - it(`parsing ${uri} throws an MongoshInvalidInputError`, () => { - try { - // eslint-disable-next-line no-new - new ConnectionString(uri); - } catch (err) { - expect(err.name).to.equal('MongoshInvalidInputError'); - return; - } - expect.fail('missed exception'); - }); - } - }); - - context('after modifications', () => { - it('allows changing hosts', () => { - const cs = new ConnectionString('mongodb://localhost'); - expect(cs.hosts).to.deep.equal(['localhost']); - - cs.hosts.push('localhost2'); - expect(cs.hosts).to.deep.equal(['localhost', 'localhost2']); - expect(cs.toString()).to.equal('mongodb://localhost,localhost2/'); - - cs.hosts = ['a', 'b', 'c']; - expect(cs.hosts).to.deep.equal(['a', 'b', 'c']); - expect(cs.toString()).to.equal('mongodb://a,b,c/'); - }); - - it('performs case-insensitive matches on connection options', () => { - const cs = new ConnectionString('mongodb://localhost/?SERVERSELECTIONTIMEOUTMS=100'); - cs.searchParams.set('serverSelectionTimeoutMS', '200'); - cs.searchParams.append('serverSelectionTimeoutMS', '300'); - - expect(cs.toString()).to.equal('mongodb://localhost/?SERVERSELECTIONTIMEOUTMS=200&SERVERSELECTIONTIMEOUTMS=300'); - expect(cs.searchParams.has('serverSelectionTimeoutMS')).to.equal(true); - expect(cs.searchParams.has('SERVERSELECTIONTIMEOUTMS')).to.equal(true); - expect(cs.searchParams.get('serverSelectionTimeoutMS')).to.equal('200'); - expect(cs.searchParams.getAll('serverSelectionTimeoutMS')).to.deep.equal(['200', '300']); - - cs.searchParams.delete('serverSelectionTimeoutMS'); - expect(cs.searchParams.has('serverSelectionTimeoutMS')).to.equal(false); - expect(cs.searchParams.has('SERVERSELECTIONTIMEOUTMS')).to.equal(false); - }); - }); - - context('cloning', () => { - it('can make copies of ConnectionString instances', () => { - const cs = new ConnectionString('mongodb://localhost'); - expect(cs.toString()).to.equal('mongodb://localhost/'); - expect(cs.clone().toString()).to.equal('mongodb://localhost/'); - }); - }); - - context('URL methods that do not apply to connection strings as-is', () => { - it('throws/returns dummy values', () => { - const cs: any = new ConnectionString('mongodb://localhost'); - expect(cs.host).not.to.equal('localhost'); - expect(cs.hostname).not.to.equal('localhost'); - expect(cs.port).to.equal(''); - expect(cs.href).to.equal('mongodb://localhost/'); - expect(() => { cs.host = 'abc'; }).to.throw(Error, /COMMON-90001/); - expect(() => { cs.hostname = 'abc'; }).to.throw(Error, /COMMON-90001/); - expect(() => { cs.port = '1000'; }).to.throw(Error, /COMMON-90001/); - expect(() => { cs.href = 'mongodb://localhost'; }).to.throw(Error, /COMMON-90001/); - }); - }); -}); diff --git a/packages/service-provider-core/src/connection-string.ts b/packages/service-provider-core/src/connection-string.ts deleted file mode 100644 index 6c1746c6db..0000000000 --- a/packages/service-provider-core/src/connection-string.ts +++ /dev/null @@ -1,152 +0,0 @@ -import assert from 'assert'; -import { CommonErrors, MongoshInvalidInputError, MongoshInternalError } from '@mongosh/errors'; -import { URL, URLSearchParams } from './whatwg-url'; - -const DUMMY_HOSTNAME = '__this_is_a_placeholder__'; - -// Adapted from the Node.js driver code: -// https://github.com/mongodb/node-mongodb-native/blob/350d14fde5b24480403313cfe5044f6e4b25f6c9/src/connection_string.ts#L146-L206 -const HOSTS_REGEX = new RegExp( - String.raw`(?mongodb(?:\+srv|)):\/\/(?:(?[^:]*)(?::(?[^@]*))?@)?(?(?!:)[^\/?@]+)(?.*)` -); - -const caseInsenstiveURLSearchParams = (Ctor: typeof URLSearchParams) => - class CaseInsenstiveURLSearchParams extends Ctor { - append(name: any, value: any): void { - return super.append(this._normalizeKey(name), value); - } - - delete(name: any): void { - return super.delete(this._normalizeKey(name)); - } - - get(name: any): string | null { - return super.get(this._normalizeKey(name)); - } - - getAll(name: any): string[] { - return super.getAll(this._normalizeKey(name)); - } - - has(name: any): boolean { - return super.has(this._normalizeKey(name)); - } - - set(name: any, value: any): void { - return super.set(this._normalizeKey(name), value); - } - - _normalizeKey(name: any): string { - name = `${name}`; - for (const key of this.keys()) { - if (key.toLowerCase() === name.toLowerCase()) { - name = key; - break; - } - } - return name; - } - }; - -// Abstract middle class to appease TypeScript, see https://github.com/microsoft/TypeScript/pull/37894 -abstract class URLWithoutHost extends URL { - abstract host: never; - abstract hostname: never; - abstract port: never; - abstract href: string; -} - -/** - * Represents a mongodb:// or mongodb+srv:// connection string. - * See: https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#reference-implementation - */ -export class ConnectionString extends URLWithoutHost { - _hosts: string[]; - - // eslint-disable-next-line complexity - constructor(uri: string) { - const match = uri.match(HOSTS_REGEX); - if (!match) { - throw new MongoshInvalidInputError(`Invalid connection string "${uri}"`, CommonErrors.InvalidArgument); - } - - const { protocol, username, password, hosts, rest } = match.groups ?? {}; - - assert(protocol); - assert(hosts); - - try { - decodeURIComponent(username ?? ''); - decodeURIComponent(password ?? ''); - } catch (err) { - throw new MongoshInvalidInputError(err.message, CommonErrors.InvalidArgument); - } - - // characters not permitted in username nor password Set([':', '/', '?', '#', '[', ']', '@']) - const illegalCharacters = new RegExp(String.raw`[:/?#\[\]@]`, 'gi'); - if (username?.match(illegalCharacters)) { - throw new MongoshInvalidInputError(`Username contains unescaped characters ${username}`, CommonErrors.InvalidArgument); - } - if (!username || !password) { - const uriWithoutProtocol = uri.replace(`${protocol}://`, ''); - if (uriWithoutProtocol.startsWith('@') || uriWithoutProtocol.startsWith(':')) { - throw new MongoshInvalidInputError('URI contained empty userinfo section', CommonErrors.InvalidArgument); - } - } - - if (password?.match(illegalCharacters)) { - throw new MongoshInvalidInputError('Password contains unescaped characters', CommonErrors.InvalidArgument); - } - - let authString = ''; - if (typeof username === 'string') authString += username; - if (typeof password === 'string') authString += `:${password}`; - if (authString) authString += '@'; - - super(`${protocol.toLowerCase()}://${authString}${DUMMY_HOSTNAME}${rest}`); - this._hosts = hosts.split(','); - - if (this.isSRV && this.hosts.length !== 1) { - throw new MongoshInvalidInputError('mongodb+srv URI cannot have multiple service names', CommonErrors.InvalidArgument); - } - if (this.isSRV && this.hosts.some(host => host.includes(':'))) { - throw new MongoshInvalidInputError('mongodb+srv URI cannot have port number', CommonErrors.InvalidArgument); - } - if (!this.pathname) { - this.pathname = '/'; - } - Object.setPrototypeOf(this.searchParams, caseInsenstiveURLSearchParams(this.searchParams.constructor as any).prototype); - } - - // The getters here should throw, but that would break .toString() because of - // https://github.com/nodejs/node/issues/36887. Using 'never' as the type - // should be enough to stop anybody from using them in TypeScript, though. - get host(): never { return DUMMY_HOSTNAME as never; } - set host(_ignored: never) { throw new MongoshInternalError('No single host for connection string'); } - get hostname(): never { return DUMMY_HOSTNAME as never; } - set hostname(_ignored: never) { throw new MongoshInternalError('No single host for connection string'); } - get port(): never { return '' as never; } - set port(_ignored: never) { throw new MongoshInternalError('No single host for connection string'); } - get href(): string { return this.toString(); } - set href(_ignored: string) { throw new MongoshInternalError('Cannot set href for connection strings'); } - - get isSRV(): boolean { - return this.protocol.includes('srv'); - } - - get hosts(): string[] { - return this._hosts; - } - - set hosts(list: string[]) { - this._hosts = list; - } - - toString(): string { - return super.toString().replace(DUMMY_HOSTNAME, this.hosts.join(',')); - } - - clone(): ConnectionString { - return new ConnectionString(this.toString()); - } -} diff --git a/packages/service-provider-core/src/index.ts b/packages/service-provider-core/src/index.ts index c6b3d1cf82..1852cdcf05 100644 --- a/packages/service-provider-core/src/index.ts +++ b/packages/service-provider-core/src/index.ts @@ -1,3 +1,4 @@ +import './textencoder-polyfill'; // for mongodb-connection-string-url in the java-shell import ServiceProvider, { ServiceProviderCore } from './service-provider'; import getConnectInfo, { ConnectInfo } from './connect-info'; import { ReplPlatform } from './platform'; @@ -23,7 +24,6 @@ import { } from 'bson'; import { bsonStringifiers } from './printable-bson'; import ShellAuthOptions from './shell-auth-options'; -import { ConnectionString } from './connection-string'; export * from './all-transport-types'; export * from './all-fle-types'; import { isFastFailureConnectionError } from './fast-failure-connect'; @@ -58,6 +58,5 @@ export { bson, bsonStringifiers, ConnectInfo, - ConnectionString, isFastFailureConnectionError }; diff --git a/packages/service-provider-core/src/whatwg-url.spec.ts b/packages/service-provider-core/src/textencoder-polyfill.spec.ts similarity index 85% rename from packages/service-provider-core/src/whatwg-url.spec.ts rename to packages/service-provider-core/src/textencoder-polyfill.spec.ts index b9786384e3..bf9b00ae59 100644 --- a/packages/service-provider-core/src/whatwg-url.spec.ts +++ b/packages/service-provider-core/src/textencoder-polyfill.spec.ts @@ -1,4 +1,4 @@ -import { textEncodingPolyfill } from './whatwg-url'; +import { textEncodingPolyfill } from './textencoder-polyfill'; import { expect } from 'chai'; describe('TextDecoder/TextEncoder polyfill', () => { diff --git a/packages/service-provider-core/src/textencoder-polyfill.ts b/packages/service-provider-core/src/textencoder-polyfill.ts new file mode 100644 index 0000000000..9f34ff2b25 --- /dev/null +++ b/packages/service-provider-core/src/textencoder-polyfill.ts @@ -0,0 +1,28 @@ +// The java-shell doesn't have URL, so we fall back to a pure-JS implementation. +// And, because it's so much fun, it also doesn't have TextEncoder/TextDecoder, +// so we need to (crudely) polyfill that as well in order to use that +// pure-JS implementation. +if ( + typeof require('util').TextDecoder !== 'function' || + typeof require('util').TextEncoder !== 'function' +) { + Object.assign(require('util'), textEncodingPolyfill()); +} + +// Basic encoder/decoder polyfill for java-shell environment (see above) +function textEncodingPolyfill(): any { + class TextEncoder { + encode(string: string): Uint8Array { + return Buffer.from(string, 'utf8'); + } + } + class TextDecoder { + decode(bytes: Uint8Array): string { + const str = Buffer.from(bytes).toString('utf8'); + return str.slice(+str.startsWith('\ufeff')); + } + } + return { TextDecoder, TextEncoder }; +} + +export { textEncodingPolyfill }; diff --git a/packages/service-provider-core/src/uri-generator.ts b/packages/service-provider-core/src/uri-generator.ts index e5b059f786..1d5442d577 100644 --- a/packages/service-provider-core/src/uri-generator.ts +++ b/packages/service-provider-core/src/uri-generator.ts @@ -3,7 +3,7 @@ import { CommonErrors, MongoshInvalidInputError } from '@mongosh/errors'; import i18n from '@mongosh/i18n'; import CliOptions from './cli-options'; -import { ConnectionString } from './connection-string'; +import ConnectionString from 'mongodb-connection-string-url'; import { DEFAULT_DB } from './index'; /** diff --git a/packages/service-provider-core/src/whatwg-url.ts b/packages/service-provider-core/src/whatwg-url.ts deleted file mode 100644 index 8db301b0a1..0000000000 --- a/packages/service-provider-core/src/whatwg-url.ts +++ /dev/null @@ -1,57 +0,0 @@ -// The java-shell doesn't have URL, so we fall back to a pure-JS implementation. -// And, because it's so much fun, it also doesn't have TextEncoder/TextDecoder, -// so we need to (crudely) polyfill that as well in order to use that -// pure-JS implementation. -if ( - typeof require('util').TextDecoder !== 'function' || - typeof require('util').TextEncoder !== 'function' -) { - Object.assign(require('util'), textEncodingPolyfill()); -} - -// Easiest way to get global `this` (either `global` in Node or `window` in -// browser) in any environment -// -// eslint-disable-next-line no-new-func -const _global = new Function('return this')(); - -// URL has to be defined dynamically to allow browser environments get rid of -// the polyfill that can potentially break them, even when not used -let URL: typeof import('url').URL; -let URLSearchParams: typeof import('url').URLSearchParams; - -// URL should be available in global scope both in Node >= 10 and in browser -// (this also means that electron renderer should have it available one way or -// another) -if ('URL' in _global) { - URL = _global.URL; - URLSearchParams = _global.URLSearchParams; -} else { - // java-shell js runtime (and older Node versions, but we don't support those) - // doesn't have URL available so we fallback to the `whatwg-url` polyfill. - // - // WARN: this polyfill is not supported in browser environment and even just - // importing it can break the browser runtime from time to time, if you are - // using `service-provider-core` in browser environment, make sure that this - // import does not actually import the library - URL = require('whatwg-url').URL; - URLSearchParams = require('whatwg-url').URLSearchParams; -} - -// Basic encoder/decoder polyfill for java-shell environment (see above) -function textEncodingPolyfill(): any { - class TextEncoder { - encode(string: string): Uint8Array { - return Buffer.from(string, 'utf8'); - } - } - class TextDecoder { - decode(bytes: Uint8Array): string { - const str = Buffer.from(bytes).toString('utf8'); - return str.slice(+str.startsWith('\ufeff')); - } - } - return { TextDecoder, TextEncoder }; -} - -export { textEncodingPolyfill, URL, URLSearchParams }; diff --git a/packages/service-provider-server/package-lock.json b/packages/service-provider-server/package-lock.json index 5fc6d368ca..55434a8445 100644 --- a/packages/service-provider-server/package-lock.json +++ b/packages/service-provider-server/package-lock.json @@ -402,8 +402,7 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "optional": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "memory-pager": { "version": "1.5.0", @@ -459,6 +458,14 @@ "prebuild-install": "6.1.2" } }, + "mongodb-connection-string-url": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-1.0.0.tgz", + "integrity": "sha512-s2kSyqM/PgvLHKzc67eK/syC4n2eXu4Q2XWA4gJOgMvOk1/bsZ8jW04EBFabfNHgw66gYSovx9F623eKEkpfGA==", + "requires": { + "whatwg-url": "^8.4.0" + } + }, "nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", @@ -583,8 +590,7 @@ "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "optional": true + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "rc": { "version": "1.2.8", @@ -788,7 +794,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.1.0.tgz", "integrity": "sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==", - "optional": true, "requires": { "punycode": "^2.1.1" } @@ -811,14 +816,12 @@ "webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", - "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", - "optional": true + "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==" }, "whatwg-url": { "version": "8.6.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.6.0.tgz", "integrity": "sha512-os0KkeeqUOl7ccdDT1qqUcS4KH4tcBTSKK5Nl5WKb2lyxInIZ/CpjkqKa1Ss12mjfdcRX9mHmPPs7/SxG1Hbdw==", - "optional": true, "requires": { "lodash": "^4.7.0", "tr46": "^2.1.0", diff --git a/packages/service-provider-server/package.json b/packages/service-provider-server/package.json index e87572d148..03360546a0 100644 --- a/packages/service-provider-server/package.json +++ b/packages/service-provider-server/package.json @@ -44,7 +44,8 @@ "@types/sinon-chai": "^3.2.3", "aws4": "^1.11.0", "mongodb": "4.0.0-beta.5", - "saslprep": "mongodb-js/saslprep#v1.0.4" + "saslprep": "mongodb-js/saslprep#v1.0.4", + "mongodb-connection-string-url": "^1.0.0" }, "devDependencies": { "@types/bl": "^2.1.0" diff --git a/packages/service-provider-server/src/cli-service-provider.integration.spec.ts b/packages/service-provider-server/src/cli-service-provider.integration.spec.ts index de9a44ea2f..a5e22e5ddc 100644 --- a/packages/service-provider-server/src/cli-service-provider.integration.spec.ts +++ b/packages/service-provider-server/src/cli-service-provider.integration.spec.ts @@ -2,7 +2,8 @@ import CliServiceProvider from './cli-service-provider'; import { expect } from 'chai'; import { MongoClient } from 'mongodb'; import { startTestServer, skipIfServerVersion } from '../../../testing/integration-testing-hooks'; -import { DbOptions, MongoClientOptions, ConnectionString } from '@mongosh/service-provider-core'; +import { DbOptions, MongoClientOptions } from '@mongosh/service-provider-core'; +import ConnectionString from 'mongodb-connection-string-url'; describe('CliServiceProvider [integration]', function() { const testServer = startTestServer('shared'); diff --git a/packages/service-provider-server/src/cli-service-provider.spec.ts b/packages/service-provider-server/src/cli-service-provider.spec.ts index 1733f580ee..8d1fc6a3b3 100644 --- a/packages/service-provider-server/src/cli-service-provider.spec.ts +++ b/packages/service-provider-server/src/cli-service-provider.spec.ts @@ -4,7 +4,7 @@ import { Collection, Db, MongoClient } from 'mongodb'; import sinonChai from 'sinon-chai'; import sinon, { StubbedInstance, stubInterface, stubConstructor } from 'ts-sinon'; import CliServiceProvider, { connectMongoClient } from './cli-service-provider'; -import { ConnectionString } from '@mongosh/service-provider-core'; +import ConnectionString from 'mongodb-connection-string-url'; import { EventEmitter } from 'events'; chai.use(sinonChai); diff --git a/packages/service-provider-server/src/cli-service-provider.ts b/packages/service-provider-server/src/cli-service-provider.ts index 25e32ed724..090d0a3207 100644 --- a/packages/service-provider-server/src/cli-service-provider.ts +++ b/packages/service-provider-server/src/cli-service-provider.ts @@ -77,7 +77,6 @@ import { ChangeStreamOptions, ChangeStream, bson as BSON, - ConnectionString, FLE, AutoEncryptionOptions, isFastFailureConnectionError @@ -85,6 +84,7 @@ import { import { MongoshCommandFailed, MongoshInternalError, MongoshRuntimeError } from '@mongosh/errors'; import { ensureMongoNodeNativePatchesAreApplied } from './mongodb-patches'; +import ConnectionString from 'mongodb-connection-string-url'; const bsonlib = { Binary, diff --git a/packages/service-provider-server/src/compass/compass-service-provider.ts b/packages/service-provider-server/src/compass/compass-service-provider.ts index 3178458608..3595fd40ce 100644 --- a/packages/service-provider-server/src/compass/compass-service-provider.ts +++ b/packages/service-provider-server/src/compass/compass-service-provider.ts @@ -1,6 +1,7 @@ import CliServiceProvider from '../cli-service-provider'; import { MongoClient } from 'mongodb'; -import { ConnectionString, ReplPlatform, MongoClientOptions } from '@mongosh/service-provider-core'; +import { ReplPlatform, MongoClientOptions } from '@mongosh/service-provider-core'; +import ConnectionString from 'mongodb-connection-string-url'; interface DataService { client: {