From 8f7a306a4875d0fb1124e67a84c7ab3eea3f8d09 Mon Sep 17 00:00:00 2001 From: Reto Rezzonico Date: Wed, 27 May 2015 16:28:51 +0200 Subject: [PATCH 1/2] Add definitions for angular-jwt --- angular-jwt/angular-jwt-tests.ts | 17 +++++++++++++++++ angular-jwt/angular-jwt.d.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 angular-jwt/angular-jwt-tests.ts create mode 100644 angular-jwt/angular-jwt.d.ts diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts new file mode 100644 index 000000000..2e7ccbc08 --- /dev/null +++ b/angular-jwt/angular-jwt-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +var app = angular.module("angular-jwt-tests", ["angular-jwt"]); + +var $jwtHelper: angular.jwt.IJwtHelper; + +var expToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8'; +var tokenPayload = $jwtHelper.decodeToken(expToken); +var date = $jwtHelper.getTokenExpirationDate(expToken); +var bool = $jwtHelper.isTokenExpired(expToken); + +var $jwtInterceptor: angular.jwt.IJwtInterceptor; + +$jwtInterceptor.tokenGetter = () => { + return expToken; +} \ No newline at end of file diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts new file mode 100644 index 000000000..ec0e03e16 --- /dev/null +++ b/angular-jwt/angular-jwt.d.ts @@ -0,0 +1,30 @@ +// Type definitions for angular-jwt 0.0.8 +// Project: https://github.com/auth0/angular-jwt +// Definitions by: Reto Rezzonico +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.jwt { + + interface JwtToken { + iss: string; + sub: string; + aud: string; + exp: number; + nbf: number; + iat: number; + jti: string; + unique_name: string; + } + + interface IJwtHelper { + decodeToken(token: string): JwtToken; + getTokenExpirationDate(token: any): Date; + isTokenExpired(token: any, offsetSeconds?: number): boolean; + } + + interface IJwtInterceptor { + tokenGetter(): string; + } +} \ No newline at end of file From 989b586b954819ef65a894634ffb0fa0ca0bb84d Mon Sep 17 00:00:00 2001 From: Reto Rezzonico Date: Wed, 27 May 2015 16:32:52 +0200 Subject: [PATCH 2/2] Linebreaks --- angular-jwt/angular-jwt-tests.ts | 2 +- angular-jwt/angular-jwt.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts index 2e7ccbc08..7f66f2611 100644 --- a/angular-jwt/angular-jwt-tests.ts +++ b/angular-jwt/angular-jwt-tests.ts @@ -14,4 +14,4 @@ var $jwtInterceptor: angular.jwt.IJwtInterceptor; $jwtInterceptor.tokenGetter = () => { return expToken; -} \ No newline at end of file +} diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts index ec0e03e16..55bb3e4f6 100644 --- a/angular-jwt/angular-jwt.d.ts +++ b/angular-jwt/angular-jwt.d.ts @@ -27,4 +27,4 @@ declare module angular.jwt { interface IJwtInterceptor { tokenGetter(): string; } -} \ No newline at end of file +}