Skip to content

Commit

Permalink
Check for values modified in deserializeAccessToken
Browse files Browse the repository at this point in the history
  • Loading branch information
korsvanloon committed Feb 20, 2024
1 parent 5667b67 commit 5107a61
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ export class FederatedToken {
Buffer.from(at, "base64").toString("ascii")
);

// Merge tokens into this object. Checking for modified tokens
for (const k in token.tokens) {
if (trackModified && !isEqual(this.tokens[k], token.tokens[k])) {
this._accessTokenModified = true;
}
}
// The value is modified if:
this._valueModified =
trackModified &&
// either a value has been modified
(!isEqual(this.values, token.values) ||
// or at least 1 token has been modified
Object.keys(token.tokens).some(
(key) => !isEqual(this.tokens[key], token.tokens[key])
));

// Merge tokens and values into "this" object.
this.tokens = {
...this.tokens,
...token.tokens,
Expand Down

0 comments on commit 5107a61

Please sign in to comment.