[EDIT] FILE: mongodb-connection-string-url.tar
README.md 0000755 00000001562 15073417771 0006046 0 ustar 00 # mongodb-connection-string-url MongoDB connection strings, based on the WhatWG URL API ```js import ConnectionString from 'mongodb-connection-string-url'; const cs = new ConnectionString('mongodb://localhost'); cs.searchParams.set('readPreference', 'secondary'); console.log(cs.href); // 'mongodb://localhost/?readPreference=secondary' ``` ## Deviations from the WhatWG URL package - URL parameters are case-insensitive - The `.host`, `.hostname` and `.port` properties cannot be set, and reading them does not return meaningful results (and are typed as `never`in TypeScript) - The `.hosts` property contains a list of all hosts in the connection string - The `.href` property cannot be set, only read - There is an additional `.isSRV` property, set to `true` for `mongodb+srv://` - There is an additional `.clone()` utility method on the prototype ## LICENSE Apache-2.0 LICENSE 0000755 00000025007 15073417771 0005574 0 ustar 00 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright 2020 MongoDB Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. package.json 0000755 00000003352 15073417771 0007054 0 ustar 00 { "name": "mongodb-connection-string-url", "version": "2.6.0", "description": "MongoDB connection strings, based on the WhatWG URL API", "keywords": [ "password", "prompt", "tty" ], "homepage": "https://github.com/mongodb-js/mongodb-connection-string-url", "repository": { "type": "git", "url": "https://github.com/mongodb-js/mongodb-connection-string-url.git" }, "bugs": { "url": "https://github.com/mongodb-js/mongodb-connection-string-url/issues" }, "main": "lib/index.js", "exports": { "require": "./lib/index.js", "import": "./.esm-wrapper.mjs" }, "files": [ "LICENSE", "lib", "package.json", "README.md", ".esm-wrapper.mjs" ], "scripts": { "lint": "eslint \"{src,test}/**/*.ts\"", "test": "npm run lint && npm run build && nyc mocha --colors -r ts-node/register test/*.ts", "build": "npm run compile-ts && gen-esm-wrapper . ./.esm-wrapper.mjs", "prepack": "npm run build", "compile-ts": "tsc -p tsconfig.json" }, "license": "Apache-2.0", "devDependencies": { "@types/chai": "^4.2.5", "@types/mocha": "^8.0.3", "@types/node": "^14.11.1", "@typescript-eslint/eslint-plugin": "^4.2.0", "@typescript-eslint/parser": "^4.2.0", "chai": "^4.2.0", "eslint": "^7.9.0", "eslint-config-semistandard": "^15.0.1", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "^2.22.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.1.3", "nyc": "^15.1.0", "ts-node": "^10.9.1", "typescript": "^4.7.4" }, "dependencies": { "@types/whatwg-url": "^8.2.1", "whatwg-url": "^11.0.0" } } .esm-wrapper.mjs 0000755 00000000410 15073417771 0007611 0 ustar 00 import mod from "./lib/index.js"; export default mod["default"]; export const CommaAndColonSeparatedRecord = mod.CommaAndColonSeparatedRecord; export const ConnectionString = mod.ConnectionString; export const redactConnectionString = mod.redactConnectionString; lib/redact.js.map 0000755 00000004751 15073417771 0007714 0 ustar 00 {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAyE;AAOzE,SAAgB,2BAA2B,CACzC,QAAoC,EACpC,OAA0C;;IAC1C,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC7B,MAAM,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,eAAe,CAAC;IACxE,MAAM,eAAe,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,mCAAI,IAAI,CAAC;IAEzD,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,eAAe,EAAE;QACrD,GAAG,CAAC,QAAQ,GAAG,iBAAiB,CAAC;QACjC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;KACnB;SAAM,IAAI,GAAG,CAAC,QAAQ,EAAE;QACvB,GAAG,CAAC,QAAQ,GAAG,iBAAiB,CAAC;KAClC;IACD,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE;QACnD,MAAM,KAAK,GAAG,IAAI,oCAA4B,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,yBA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C,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;KAC3F;IAID,MAAM,CAAC,GAAG,iBAAiB,CAAC;IAC5B,MAAM,YAAY,GAAgC;QAEhD,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,EAAE,KAAK,CAAC,IAAI,CAAC;QAE3F,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,sCAAsC,EAAE,KAAK,CAAC,EAAE,CAAC;QAEpE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,2CAA2C,EAAE,KAAK,CAAC,EAAE,CAAC;QAEzE,GAAG,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG;QAEjF,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC;KAC1D,CAAC;IACF,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;QACnC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;KACrB;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AApCD,wDAoCC"} lib/redact.d.ts 0000755 00000000647 15073417771 0007374 0 ustar 00 import ConnectionString from './index'; export interface ConnectionStringRedactionOptions { redactUsernames?: boolean; replacementString?: string; } export declare function redactValidConnectionString(inputUrl: Readonly<ConnectionString>, options?: ConnectionStringRedactionOptions): ConnectionString; export declare function redactConnectionString(uri: string, options?: ConnectionStringRedactionOptions): string; lib/index.js.map 0000755 00000015506 15073417771 0007561 0 ustar 00 {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAkD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9B,KAAK,EAAE,CAAC;QACR,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YAC3C,IAAI,CAAC,KAAK;gBAAE,SAAS;YACrB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEtC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;gBACrB,IAAI,CAAC,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,CAAC;aAC3C;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAuB,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;aACzF;SACF;IACH,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF;AAlBD,oEAkBC;AAED,kBAAe,gBAAgB,CAAC"} lib/index.d.ts 0000755 00000005021 15073417771 0007230 0 ustar 00 import { URL } from 'whatwg-url'; import { redactConnectionString, ConnectionStringRedactionOptions } from './redact'; export { redactConnectionString, ConnectionStringRedactionOptions }; declare class CaseInsensitiveMap<K extends string = string> extends Map<K, string> { delete(name: K): boolean; get(name: K): string | undefined; has(name: K): boolean; set(name: K, value: any): this; _normalizeKey(name: any): K; } declare abstract class URLWithoutHost extends URL { abstract get host(): never; abstract set host(value: never); abstract get hostname(): never; abstract set hostname(value: never); abstract get port(): never; abstract set port(value: never); abstract get href(): string; abstract set href(value: string); } export interface ConnectionStringParsingOptions { looseValidation?: boolean; } export declare class ConnectionString extends URLWithoutHost { _hosts: string[]; constructor(uri: string, options?: ConnectionStringParsingOptions); get host(): never; set host(_ignored: never); get hostname(): never; set hostname(_ignored: never); get port(): never; set port(_ignored: never); get href(): string; set href(_ignored: string); get isSRV(): boolean; get hosts(): string[]; set hosts(list: string[]); toString(): string; clone(): ConnectionString; redact(options?: ConnectionStringRedactionOptions): ConnectionString; typedSearchParams<T extends {}>(): { append(name: keyof T & string, value: any): void; delete(name: keyof T & string): void; get(name: keyof T & string): string | null; getAll(name: keyof T & string): string[]; has(name: keyof T & string): boolean; set(name: keyof T & string, value: any): void; keys(): IterableIterator<keyof T & string>; values(): IterableIterator<string>; entries(): IterableIterator<[keyof T & string, string]>; _normalizeKey(name: keyof T & string): string; [Symbol.iterator](): IterableIterator<[keyof T & string, string]>; sort(): void; forEach<THIS_ARG = void>(callback: (this: THIS_ARG, value: string, name: string, searchParams: any) => void, thisArg?: THIS_ARG | undefined): void; readonly [Symbol.toStringTag]: "URLSearchParams"; }; } export declare class CommaAndColonSeparatedRecord<K extends {} = Record<string, unknown>> extends CaseInsensitiveMap<keyof K & string> { constructor(from?: string | null); toString(): string; } export default ConnectionString; lib/redact.js 0000755 00000007757 15073417771 0007151 0 ustar 00 "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.redactConnectionString = exports.redactValidConnectionString = void 0; const index_1 = __importStar(require("./index")); function redactValidConnectionString(inputUrl, options) { var _a, _b; const url = inputUrl.clone(); const replacementString = (_a = options === null || options === void 0 ? void 0 : options.replacementString) !== null && _a !== void 0 ? _a : '_credentials_'; const redactUsernames = (_b = options === null || options === void 0 ? void 0 : options.redactUsernames) !== null && _b !== void 0 ? _b : true; if ((url.username || url.password) && redactUsernames) { url.username = replacementString; url.password = ''; } else if (url.password) { url.password = replacementString; } if (url.searchParams.has('authMechanismProperties')) { const props = new index_1.CommaAndColonSeparatedRecord(url.searchParams.get('authMechanismProperties')); if (props.get('AWS_SESSION_TOKEN')) { props.set('AWS_SESSION_TOKEN', replacementString); url.searchParams.set('authMechanismProperties', props.toString()); } } if (url.searchParams.has('tlsCertificateKeyFilePassword')) { url.searchParams.set('tlsCertificateKeyFilePassword', replacementString); } if (url.searchParams.has('proxyUsername') && redactUsernames) { url.searchParams.set('proxyUsername', replacementString); } if (url.searchParams.has('proxyPassword')) { url.searchParams.set('proxyPassword', replacementString); } return url; } exports.redactValidConnectionString = redactValidConnectionString; function redactConnectionString(uri, options) { var _a, _b; const replacementString = (_a = options === null || options === void 0 ? void 0 : options.replacementString) !== null && _a !== void 0 ? _a : '<credentials>'; const redactUsernames = (_b = options === null || options === void 0 ? void 0 : options.redactUsernames) !== null && _b !== void 0 ? _b : true; let parsed; try { parsed = new index_1.default(uri); } catch (_c) { } if (parsed) { options = { ...options, replacementString: '___credentials___' }; return parsed.redact(options).toString().replace(/___credentials___/g, replacementString); } const R = replacementString; const replacements = [ uri => uri.replace(redactUsernames ? /(\/\/)(.*)(@)/g : /(\/\/[^@]*:)(.*)(@)/g, `$1${R}$3`), uri => uri.replace(/(AWS_SESSION_TOKEN(:|%3A))([^,&]+)/gi, `$1${R}`), uri => uri.replace(/(tlsCertificateKeyFilePassword=)([^&]+)/gi, `$1${R}`), uri => redactUsernames ? uri.replace(/(proxyUsername=)([^&]+)/gi, `$1${R}`) : uri, uri => uri.replace(/(proxyPassword=)([^&]+)/gi, `$1${R}`) ]; for (const replacer of replacements) { uri = replacer(uri); } return uri; } exports.redactConnectionString = redactConnectionString; //# sourceMappingURL=redact.js.map lib/index.js 0000755 00000017737 15073417771 0007015 0 ustar 00 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommaAndColonSeparatedRecord = exports.ConnectionString = exports.redactConnectionString = void 0; const whatwg_url_1 = require("whatwg-url"); const redact_1 = require("./redact"); Object.defineProperty(exports, "redactConnectionString", { enumerable: true, get: function () { return redact_1.redactConnectionString; } }); const DUMMY_HOSTNAME = '__this_is_a_placeholder__'; function connectionStringHasValidScheme(connectionString) { return (connectionString.startsWith('mongodb://') || connectionString.startsWith('mongodb+srv://')); } const HOSTS_REGEX = /^(?<protocol>[^/]+):\/\/(?:(?<username>[^:@]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^/?@]*)(?<rest>.*)/; class CaseInsensitiveMap extends Map { delete(name) { return super.delete(this._normalizeKey(name)); } get(name) { return super.get(this._normalizeKey(name)); } has(name) { return super.has(this._normalizeKey(name)); } set(name, value) { return super.set(this._normalizeKey(name), value); } _normalizeKey(name) { name = `${name}`; for (const key of this.keys()) { if (key.toLowerCase() === name.toLowerCase()) { name = key; break; } } return name; } } function caseInsenstiveURLSearchParams(Ctor) { return class CaseInsenstiveURLSearchParams extends Ctor { append(name, value) { return super.append(this._normalizeKey(name), value); } delete(name) { return super.delete(this._normalizeKey(name)); } get(name) { return super.get(this._normalizeKey(name)); } getAll(name) { return super.getAll(this._normalizeKey(name)); } has(name) { return super.has(this._normalizeKey(name)); } set(name, value) { return super.set(this._normalizeKey(name), value); } keys() { return super.keys(); } values() { return super.values(); } entries() { return super.entries(); } [Symbol.iterator]() { return super[Symbol.iterator](); } _normalizeKey(name) { return CaseInsensitiveMap.prototype._normalizeKey.call(this, name); } }; } class URLWithoutHost extends whatwg_url_1.URL { } class MongoParseError extends Error { get name() { return 'MongoParseError'; } } class ConnectionString extends URLWithoutHost { constructor(uri, options = {}) { var _a; const { looseValidation } = options; if (!looseValidation && !connectionStringHasValidScheme(uri)) { throw new MongoParseError('Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"'); } const match = uri.match(HOSTS_REGEX); if (!match) { throw new MongoParseError(`Invalid connection string "${uri}"`); } const { protocol, username, password, hosts, rest } = (_a = match.groups) !== null && _a !== void 0 ? _a : {}; if (!looseValidation) { if (!protocol || !hosts) { throw new MongoParseError(`Protocol and host list are required in "${uri}"`); } try { decodeURIComponent(username !== null && username !== void 0 ? username : ''); decodeURIComponent(password !== null && password !== void 0 ? password : ''); } catch (err) { throw new MongoParseError(err.message); } const illegalCharacters = /[:/?#[\]@]/gi; if (username === null || username === void 0 ? void 0 : username.match(illegalCharacters)) { throw new MongoParseError(`Username contains unescaped characters ${username}`); } if (!username || !password) { const uriWithoutProtocol = uri.replace(`${protocol}://`, ''); if (uriWithoutProtocol.startsWith('@') || uriWithoutProtocol.startsWith(':')) { throw new MongoParseError('URI contained empty userinfo section'); } } if (password === null || password === void 0 ? void 0 : password.match(illegalCharacters)) { throw new MongoParseError('Password contains unescaped characters'); } } let authString = ''; if (typeof username === 'string') authString += username; if (typeof password === 'string') authString += `:${password}`; if (authString) authString += '@'; try { super(`${protocol.toLowerCase()}://${authString}${DUMMY_HOSTNAME}${rest}`); } catch (err) { if (looseValidation) { new ConnectionString(uri, { ...options, looseValidation: false }); } if (typeof err.message === 'string') { err.message = err.message.replace(DUMMY_HOSTNAME, hosts); } throw err; } this._hosts = hosts.split(','); if (!looseValidation) { if (this.isSRV && this.hosts.length !== 1) { throw new MongoParseError('mongodb+srv URI cannot have multiple service names'); } if (this.isSRV && this.hosts.some(host => host.includes(':'))) { throw new MongoParseError('mongodb+srv URI cannot have port number'); } } if (!this.pathname) { this.pathname = '/'; } Object.setPrototypeOf(this.searchParams, caseInsenstiveURLSearchParams(this.searchParams.constructor).prototype); } get host() { return DUMMY_HOSTNAME; } set host(_ignored) { throw new Error('No single host for connection string'); } get hostname() { return DUMMY_HOSTNAME; } set hostname(_ignored) { throw new Error('No single host for connection string'); } get port() { return ''; } set port(_ignored) { throw new Error('No single host for connection string'); } get href() { return this.toString(); } set href(_ignored) { throw new Error('Cannot set href for connection strings'); } get isSRV() { return this.protocol.includes('srv'); } get hosts() { return this._hosts; } set hosts(list) { this._hosts = list; } toString() { return super.toString().replace(DUMMY_HOSTNAME, this.hosts.join(',')); } clone() { return new ConnectionString(this.toString(), { looseValidation: true }); } redact(options) { return (0, redact_1.redactValidConnectionString)(this, options); } typedSearchParams() { const sametype = false && new (caseInsenstiveURLSearchParams(whatwg_url_1.URLSearchParams))(); return this.searchParams; } [Symbol.for('nodejs.util.inspect.custom')]() { const { href, origin, protocol, username, password, hosts, pathname, search, searchParams, hash } = this; return { href, origin, protocol, username, password, hosts, pathname, search, searchParams, hash }; } } exports.ConnectionString = ConnectionString; class CommaAndColonSeparatedRecord extends CaseInsensitiveMap { constructor(from) { super(); for (const entry of (from !== null && from !== void 0 ? from : '').split(',')) { if (!entry) continue; const colonIndex = entry.indexOf(':'); if (colonIndex === -1) { this.set(entry, ''); } else { this.set(entry.slice(0, colonIndex), entry.slice(colonIndex + 1)); } } } toString() { return [...this].map(entry => entry.join(':')).join(','); } } exports.CommaAndColonSeparatedRecord = CommaAndColonSeparatedRecord; exports.default = ConnectionString; //# sourceMappingURL=index.js.map
SAVE
CANCEL