Skip to content

Commit 835fe1b

Browse files
committed
wip
1 parent ea8a33f commit 835fe1b

File tree

20 files changed

+52
-54
lines changed

20 files changed

+52
-54
lines changed

src/client-side-encryption/auto_encrypter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export class AutoEncrypter {
160160
_mongocrypt: MongoCrypt;
161161

162162
/**
163+
* @internal
163164
* Used by devtools to enable decorating decryption results.
164165
*
165166
* When set and enabled, `decrypt` will automatically recursively

src/cmap/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ export class CryptoConnection extends Connection {
889889

890890
const decryptedResponse = responseType?.make(result) ?? deserialize(result, options);
891891

892-
if (autoEncrypter[kDecorateResult]) {
892+
if (autoEncrypter.__decorateDecryptionResult) {
893893
if (responseType == null) {
894894
decorateDecryptionResult(decryptedResponse, encryptedResponse.toObject(), true);
895895
} else if (decryptedResponse instanceof CursorResponse) {

src/cmap/wire_protocol/responses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ export class MongoDBResponse extends OnDemandDocument {
221221
export class CursorResponse extends MongoDBResponse {
222222
/**
223223
* Devtools need to know which keys were encrypted before the driver automatically decrypted them.
224-
* If decorating is enabled (`Symbol.for('@@mdb.decorateDecryptionResult')`), this field will be set,
224+
* If decorating is enabled (`__decorateDecryptionResult`), this field will be set,
225225
* storing the original encrypted response from the server, so that we can build an object that has
226-
* the list of BSON keys that were encrypted stored at a well known symbol: `Symbol.for('@@mdb.decryptedKeys')`.
226+
* the list of BSON keys that were encrypted stored at a well known symbol: `__decryptedKeys`.
227227
*/
228228
encryptedResponse?: MongoDBResponse;
229229
/**

src/connection_string.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ export function parseOptions(
249249

250250
const mongoOptions = Object.create(null);
251251

252-
// Feature flags
253-
for (const flag of Object.getOwnPropertySymbols(options)) {
254-
if (FEATURE_FLAGS.has(flag)) {
255-
mongoOptions[flag] = options[flag];
256-
}
257-
}
258-
259252
mongoOptions.hosts = isSRV ? [] : hosts.map(HostAddress.fromString);
260253

261254
const urlOptions = new CaseInsensitiveMap<unknown[]>();
@@ -515,7 +508,7 @@ export function parseOptions(
515508
);
516509
}
517510

518-
const loggerFeatureFlag = Symbol.for('@@mdb.enableMongoLogger');
511+
const loggerFeatureFlag = '__enableMongoLogger';
519512
mongoOptions[loggerFeatureFlag] = mongoOptions[loggerFeatureFlag] ?? false;
520513

521514
let loggerEnvOptions: MongoLoggerEnvOptions = {};
@@ -530,7 +523,7 @@ export function parseOptions(
530523
MONGODB_LOG_ALL: process.env.MONGODB_LOG_ALL,
531524
MONGODB_LOG_MAX_DOCUMENT_LENGTH: process.env.MONGODB_LOG_MAX_DOCUMENT_LENGTH,
532525
MONGODB_LOG_PATH: process.env.MONGODB_LOG_PATH,
533-
...mongoOptions[Symbol.for('@@mdb.internalLoggerConfig')]
526+
...mongoOptions['__internalLoggerConfig']
534527
};
535528
loggerClientOptions = {
536529
mongodbLogPath: mongoOptions.mongodbLogPath,
@@ -1331,7 +1324,7 @@ export const DEFAULT_OPTIONS = new CaseInsensitiveMap(
13311324
* @internal
13321325
*/
13331326
export const FEATURE_FLAGS = new Set([
1334-
Symbol.for('@@mdb.skipPingOnConnect'),
1335-
Symbol.for('@@mdb.enableMongoLogger'),
1336-
Symbol.for('@@mdb.internalLoggerConfig')
1327+
'__skipPingOnConnect',
1328+
'__enableMongoLogger',
1329+
'__internalLoggerConfig'
13371330
]);

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,6 @@ export const LEGACY_HELLO_COMMAND_CAMEL_CASE = 'isMaster';
172172
// the objects (and class) that we expect to see them on and prevent TS
173173
// errors.
174174
/** @internal */
175-
export const kDecorateResult = Symbol.for('@@mdb.decorateDecryptionResult');
175+
export const kDecorateResult = '__decorateDecryptionResult';
176176
/** @internal */
177-
export const kDecoratedKeys = Symbol.for('@@mdb.decryptedKeys');
177+
export const kDecoratedKeys = '__decryptedKeys';

src/mongo_client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
299299
mongodbLogMaxDocumentLength?: number;
300300

301301
/** @internal */
302-
[featureFlag: symbol]: any;
302+
__skipPingOnConnect?: boolean;
303+
/** @internal */
304+
__internalLoggerConfig?: any;
305+
/** @internal */
306+
__enableMongoLogger?: boolean;
303307
}
304308

305309
/** @public */

src/operations/execute_operation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async function autoConnect(client: MongoClient): Promise<Topology> {
131131
if (client.s.hasBeenClosed) {
132132
throw new MongoNotConnectedError('Client must be connected before running operations');
133133
}
134-
client.s.options[Symbol.for('@@mdb.skipPingOnConnect')] = true;
134+
client.s.options[__skipPingOnConnect] = true;
135135
try {
136136
await client.connect();
137137
if (client.topology == null) {
@@ -141,7 +141,7 @@ async function autoConnect(client: MongoClient): Promise<Topology> {
141141
}
142142
return client.topology;
143143
} finally {
144-
delete client.s.options[Symbol.for('@@mdb.skipPingOnConnect')];
144+
delete client.s.options[__skipPingOnConnect];
145145
}
146146
}
147147
return client.topology;

src/sdam/topology.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
471471
readPreferenceServerSelector(readPreference),
472472
selectServerOptions
473473
);
474-
const skipPingOnConnect = this.s.options[Symbol.for('@@mdb.skipPingOnConnect')] === true;
474+
const skipPingOnConnect = this.s.options[__skipPingOnConnect] === true;
475475
if (!skipPingOnConnect && this.s.credentials) {
476476
await server.command(ns('admin.$cmd'), { ping: 1 }, { timeoutContext });
477477
stateTransition(this, STATE_CONNECTED);

test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CapturingMongoClient extends MongoClient {
3434
commandStartedEvents: Array<CommandStartedEvent> = [];
3535
clientsCreated = 0;
3636
constructor(url: string, options: MongoClientOptions = {}) {
37-
options = { ...options, monitorCommands: true, [Symbol.for('@@mdb.skipPingOnConnect')]: true };
37+
options = { ...options, monitorCommands: true, [__skipPingOnConnect]: true };
3838
if (process.env.MONGODB_API_VERSION) {
3939
options.serverApi = process.env.MONGODB_API_VERSION as MongoClientOptions['serverApi'];
4040
}

test/integration/client-side-encryption/driver.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ describe('Client Side Encryption Functional', function () {
394394
}
395395
);
396396

397-
encryptedClient.autoEncrypter[Symbol.for('@@mdb.decorateDecryptionResult')] = true;
397+
encryptedClient.autoEncrypter[__decorateDecryptionResult] = true;
398398
await encryptedClient.connect();
399399
});
400400

@@ -418,13 +418,13 @@ describe('Client Side Encryption Functional', function () {
418418

419419
expect(decrypted).to.deep.equal(data);
420420
expect(decrypted)
421-
.to.have.property(Symbol.for('@@mdb.decryptedKeys'))
421+
.to.have.property(__decryptedKeys)
422422
.that.deep.equals(['a', 'b']);
423423

424424
// Nested
425425
expect(decrypted).to.have.property('c');
426426
expect(decrypted.c)
427-
.to.have.property(Symbol.for('@@mdb.decryptedKeys'))
427+
.to.have.property(__decryptedKeys)
428428
.that.deep.equals(['d']);
429429
});
430430
}

0 commit comments

Comments
 (0)