Skip to content

Commit

Permalink
BREAKING CHANGE: support generic UserClaims type
Browse files Browse the repository at this point in the history
OKTA-419985
<<<Jenkins Check-In of Tested SHA: a793ce8 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 3
PR Link: "#1003"
  • Loading branch information
shuowu authored and aarongranick-okta committed Jan 7, 2022
1 parent 43ba730 commit b164572
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/types/UserClaims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/* eslint-disable camelcase */
export interface UserClaims {
export type UserClaims<T = {}> = T & {
auth_time?: number;
aud?: string;
email?: string;
Expand All @@ -37,5 +37,5 @@ export interface UserClaims {
updated_at?: number;
ver?: number;
zoneinfo?: string;
[propName: string]: any; // For custom claims that may be configured by the org admin
at_hash?: string;
}
2 changes: 1 addition & 1 deletion test/apps/app/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function tokensHTML(tokens: Tokens): string {
</thead>
<tbody>
${
Object.keys(claims).map((key) => {
Object.keys(claims).map((key: keyof UserClaims) => {
return `<tr><td>${key}</td><td>${claims[key]}</td></tr>`;
}).join('\n')
}
Expand Down
4 changes: 4 additions & 0 deletions test/types/auth.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const authorizeOptions2: TokenParams = {
// User
expectType<boolean>(await authClient.isAuthenticated());
expectType<UserClaims>(await authClient.getUser());
const user = { sub: 'sub', groups: ['fake group'] };
expectAssignable<UserClaims<{
groups: string[];
}>>(user);

// Redirect
expectType<boolean>(authClient.isLoginRedirect());
Expand Down

0 comments on commit b164572

Please sign in to comment.