fix: Error thrown when running `DocumentStore.initialize()` with an insecure connection when passing `AuthOptions`, even if no certificate was passed. #412
This PR fixes an error being thrown when DocumentStore.initialize() is run after creating a DocumentStore passing AuthOptions that do not contain a certificate.
In essence, this means that the user is forced to write the following verbose construction if they have a case where their certificate is possibly undefined:
let store: DocumentStore;
if (certificate) {
store = new DocumentStore(host, database, { certificate, type: "pfx" });
} else {
store = new DocumentStore(host, database);
}
store.initialize();
Instead of:
// This interface is agnostic to whether `certificate` is present or not, if it's not provided, it will just assume an insecure connection.
const store = new DocumentStore(host, database, { certificate, type: "pfx" });
store.initialize();
Given that this piece of code currently throws:
const store = new DocumentStore(host, database, { certificate: undefined, type: "pfx" });
store.initialize(); // Throws.
This PR fixes an error being thrown when
DocumentStore.initialize()
is run after creating aDocumentStore
passingAuthOptions
that do not contain a certificate.In essence, this means that the user is forced to write the following verbose construction if they have a case where their
certificate
is possibly undefined:Instead of:
Given that this piece of code currently throws: