Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
include all response values in signin response
Browse files Browse the repository at this point in the history
  • Loading branch information
kherock committed Apr 29, 2021
1 parent defaadb commit d95e47a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ export class User {
expires_at: number;
/** The custom state transferred in the last signin */
state: any;
/** Other claims sent in the token response */
otherClaims: Record<string, any>;
/** Other values sent in the token response */
otherValues: Record<string, any>;

toStorageString(): string;
static fromStorageString(storageString: string): User;
Expand Down
6 changes: 4 additions & 2 deletions src/ResponseValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ export class ResponseValidator {

return this._tokenClient.exchangeCode(request).then(tokenResponse => {

for(var key in tokenResponse) {
response[key] = tokenResponse[key];
for (var key in tokenResponse) {
if (Object.prototype.hasOwnProperty.call(tokenResponse, key)) {
response[key] = tokenResponse[key];
}
}

if (response.id_token) {
Expand Down
18 changes: 5 additions & 13 deletions src/SigninResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@ export class SigninResponse {

var values = UrlUtility.parseUrlFragment(url, delimiter);

this.error = values.error;
this.error_description = values.error_description;
this.error_uri = values.error_uri;

this.code = values.code;
this.state = values.state;
this.id_token = values.id_token;
this.session_state = values.session_state;
this.access_token = values.access_token;
this.token_type = values.token_type;
this.scope = values.scope;
for (var key in values) {
if (Object.prototype.hasOwnProperty.call(values, key)) {
this[key] = values[key];
}
}
this.profile = undefined; // will be set from ResponseValidator

this.expires_in = values.expires_in;
}

get expires_in() {
Expand Down
4 changes: 2 additions & 2 deletions src/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Log } from './Log.js';

export class User {
constructor({id_token, session_state, access_token, refresh_token, token_type, scope, profile, expires_at, state, ...otherClaims}) {
constructor({id_token, session_state, access_token, refresh_token, token_type, scope, profile, expires_at, state, ...otherValues}) {
this.id_token = id_token;
this.session_state = session_state;
this.access_token = access_token;
Expand All @@ -14,7 +14,7 @@ export class User {
this.profile = profile;
this.expires_at = expires_at;
this.state = state;
this.otherClaims = otherClaims;
this.otherValues = otherValues;
}

get expires_in() {
Expand Down

0 comments on commit d95e47a

Please sign in to comment.