Skip to content

Commit

Permalink
fix: IdentitiesManager.putToken now uses Object.definePriority to…
Browse files Browse the repository at this point in the history
… avoid serialisation issues when the `identityId` is `__proto__`
  • Loading branch information
amydevs committed Oct 26, 2023
1 parent 9e1e869 commit 8142056
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/identities/IdentitiesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8142056

Please sign in to comment.