Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit fa0ad66

Browse files
fix: Don't allow serialization of firestore settings (#1742)
* Dont allow serialization of firestore settings When logging any firestore object like WriteBatch,Transaction,etc the settings object also gets logged / exposed This can be seen by running JSON.stringify on any firestore object even a document reference Many developers log firestore objects to help them debug testing/prod issues, this leaking of entire firestore key via this._settings is a bad practice as per me We can also use Object.defineProperty to make it non-enumerable or any other technique that you like * Fix formatting. * Only redact credentials. Co-authored-by: Ehsan Nasiri <[email protected]>
1 parent a67a124 commit fa0ad66

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

dev/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,13 @@ export class Firestore implements firestore.Firestore {
652652
}
653653

654654
this._settings = settings;
655+
this._settings.toJson = function () {
656+
const temp = Object.assign({}, this);
657+
if (temp.credentials) {
658+
temp.credentials = {private_key: '***', client_email: '***'};
659+
}
660+
return temp;
661+
};
655662
this._serializer = new Serializer(this);
656663
}
657664

0 commit comments

Comments
 (0)