Skip to content

Commit

Permalink
fix: support non-standard user info properties (#422)
Browse files Browse the repository at this point in the history
closes #421
  • Loading branch information
Nick Woodward committed May 12, 2020
1 parent fd3e106 commit 7ac2274
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/id-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class IDToken {

export declare namespace IDToken {
export interface UserInfo {
[key: string]: any;

/**
* Issuer Identifier for the Issuer of the response.
*/
Expand Down
12 changes: 12 additions & 0 deletions test/unit/utils/id-token.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe('IDToken', () => {
});
});

it('should support accessing non-standard properties', () => {
const user = IDToken.parse(`0.${btoa(
JSON.stringify({
sub: '1234567890',
name: 'John Doe',
hello: 'world'
})
)}.0`);

expect(user.hello).equals('world');
});

it('should support decoding base64 url encoded tokens', () => {
const user = IDToken.parse(`0.${encode(
JSON.stringify({
Expand Down

0 comments on commit 7ac2274

Please sign in to comment.