Skip to content

Commit ce01226

Browse files
committed
Merge pull request DefinitelyTyped#4468 from rerezz/master
Add definitions for angular-jwt
2 parents 3824fcf + 989b586 commit ce01226

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

angular-jwt/angular-jwt-tests.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="../angularjs/angular.d.ts" />
2+
/// <reference path="angular-jwt.d.ts" />
3+
4+
var app = angular.module("angular-jwt-tests", ["angular-jwt"]);
5+
6+
var $jwtHelper: angular.jwt.IJwtHelper;
7+
8+
var expToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8';
9+
var tokenPayload = $jwtHelper.decodeToken(expToken);
10+
var date = $jwtHelper.getTokenExpirationDate(expToken);
11+
var bool = $jwtHelper.isTokenExpired(expToken);
12+
13+
var $jwtInterceptor: angular.jwt.IJwtInterceptor;
14+
15+
$jwtInterceptor.tokenGetter = () => {
16+
return expToken;
17+
}

angular-jwt/angular-jwt.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Type definitions for angular-jwt 0.0.8
2+
// Project: https://github.com/auth0/angular-jwt
3+
// Definitions by: Reto Rezzonico <https://github.com/rerezz>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../angularjs/angular.d.ts" />
7+
8+
declare module angular.jwt {
9+
10+
interface JwtToken {
11+
iss: string;
12+
sub: string;
13+
aud: string;
14+
exp: number;
15+
nbf: number;
16+
iat: number;
17+
jti: string;
18+
unique_name: string;
19+
}
20+
21+
interface IJwtHelper {
22+
decodeToken(token: string): JwtToken;
23+
getTokenExpirationDate(token: any): Date;
24+
isTokenExpired(token: any, offsetSeconds?: number): boolean;
25+
}
26+
27+
interface IJwtInterceptor {
28+
tokenGetter(): string;
29+
}
30+
}

0 commit comments

Comments
 (0)