Skip to content

Commit

Permalink
fix tsd
Browse files Browse the repository at this point in the history
  • Loading branch information
shuowu committed Apr 6, 2022
1 parent d3ff4f8 commit 5553078
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/types/JWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export interface JWTHeader {
x5t?: string;
}

export type JWTPayload = UserClaims & {
scp?: string[];
}

export interface JWTObject {
header: JWTHeader;
payload: UserClaims & {
scp?: string[];
};
payload: JWTPayload;
signature: string;
}
5 changes: 3 additions & 2 deletions test/types/token.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
TokenResponse,
JWTObject,
RefreshToken,
OktaAuth
OktaAuth,
JWTPayload
} from '@okta/okta-auth-js';
import { expectType, expectAssignable } from 'tsd';

Expand Down Expand Up @@ -95,7 +96,7 @@ const tokens = {

const decodedToken = authClient.token.decode('ID_TOKEN_JWT');
expectType<JWTObject>(decodedToken);
expectType<UserClaims>(decodedToken.payload);
expectType<JWTPayload>(decodedToken.payload);
expectType<string>(decodedToken.header.alg);
expectType<string>(decodedToken.signature);

Expand Down

0 comments on commit 5553078

Please sign in to comment.