diff --git a/src/identities/IdentitiesManager.ts b/src/identities/IdentitiesManager.ts index 201ee93eb5..c5aa731b6e 100644 --- a/src/identities/IdentitiesManager.ts +++ b/src/identities/IdentitiesManager.ts @@ -206,7 +206,15 @@ class IdentitiesManager { ); } const providerTokens = await this.getTokens(providerId); - providerTokens[identityId] = providerToken; + // This has to be done in case the key is `__proto__`. + // Otherwise, the object will not be correctly serialized. + // https://github.com/MatrixAI/Polykey/issues/608 + Object.defineProperty(providerTokens, identityId, { + value: providerToken, + writable: true, + enumerable: true, + configurable: true, + }); const providerIdPath = [ ...this.identitiesTokensDbPath, providerId,