@@ -22,6 +22,8 @@ var AccessToken = (function () {
22
22
function AccessToken ( client , _ref ) {
23
23
var access_token = _ref . access_token ;
24
24
var refresh_token = _ref . refresh_token ;
25
+ var created_at = _ref . created_at ;
26
+ var expires_in = _ref . expires_in ;
25
27
var scope = _ref . scope ;
26
28
27
29
_classCallCheck ( this , AccessToken ) ;
@@ -30,6 +32,8 @@ var AccessToken = (function () {
30
32
this . client = client ;
31
33
this . accessToken = access_token ; // eslint-disable-line camelcase
32
34
this . refreshToken = refresh_token ; // eslint-disable-line camelcase
35
+ this . createdAt = created_at ; // eslint-disable-line camelcase
36
+ this . expiresIn = expires_in ; // eslint-disable-line camelcase
33
37
this . scope = scope ;
34
38
this . http = this . client . http . set ( 'Authorization' , 'Bearer ' + this . accessToken ) ;
35
39
_lodash2 [ 'default' ] . assign ( this , this . client . accessTokenMixin ) ;
@@ -41,9 +45,18 @@ var AccessToken = (function () {
41
45
return {
42
46
access_token : this . accessToken , // eslint-disable-line camelcase
43
47
refresh_token : this . refreshToken , // eslint-disable-line camelcase
48
+ created_at : createdAt , // eslint-disable-line camelcase
49
+ expires_in : expiresIn , // eslint-disable-line camelcase
44
50
scope : this . scope
45
51
} ;
46
52
}
53
+ } , {
54
+ key : 'isExpired' ,
55
+ value : function isExpired ( ) {
56
+ var expiresAt = ( this . createdAt + this . expiresIn ) * 1000 ;
57
+ var now = new Date ( ) . getTime ( ) ;
58
+ return expiresAt < now ;
59
+ }
47
60
} , {
48
61
key : 'refresh' ,
49
62
value : function refresh ( ) {
0 commit comments