@eximchain/dappbot-api-client
Advanced tools
Comparing version
@@ -0,1 +1,4 @@ | ||
# v1.2.3 | ||
Upgrading to get a hotfix for the underlying `hasStaleAuth()` checker. Also surfacing the `authStatus()` helper directly on the API object, supporting calls like `let { isActive, isStale, isEmpty } = API.authStatus()`; | ||
# v1.2.2 | ||
@@ -2,0 +5,0 @@ Upgraded the `API.isAuth...()` helper functions to rely on the new `User.authStatus()` helper function from `dappbot-types@1.7.6`. |
@@ -136,2 +136,11 @@ "use strict"; | ||
/** | ||
* Check whether the API's authData is | ||
* active, stale, or empty with one call. | ||
* The more specific functions rely on | ||
* this one. | ||
*/ | ||
API.prototype.authStatus = function () { | ||
return user_1.default.authStatus(this.authData); | ||
}; | ||
/** | ||
* Helper to check the API's authData: only | ||
@@ -142,3 +151,3 @@ * `true` if the authData is both non-null | ||
API.prototype.hasActiveAuth = function () { | ||
return user_1.default.authStatus(this.authData).isActive; | ||
return this.authStatus().isActive; | ||
}; | ||
@@ -151,7 +160,3 @@ /** | ||
API.prototype.hasStaleAuth = function () { | ||
return user_1.default.authStatus(this.authData).isStale; | ||
if (this.hasNoAuth()) | ||
return false; | ||
var expiryDate = Date.parse(this.authData.ExpiresAt); | ||
return expiryDate !== NaN && Date.now() > expiryDate; | ||
return this.authStatus().isStale; | ||
}; | ||
@@ -164,3 +169,3 @@ /** | ||
API.prototype.hasNoAuth = function () { | ||
return user_1.default.authStatus(this.authData).isEmpty; | ||
return this.authStatus().isEmpty; | ||
}; | ||
@@ -167,0 +172,0 @@ return API; |
{ | ||
"name": "@eximchain/dappbot-api-client", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Typescript client for the DappBot API", | ||
@@ -26,3 +26,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@eximchain/dappbot-types": "^1.7.6", | ||
"@eximchain/dappbot-types": "^1.7.8", | ||
"@types/axios": "^0.14.0", | ||
@@ -29,0 +29,0 @@ "@types/lodash.omit": "^4.5.6", |
@@ -115,2 +115,12 @@ import User from '@eximchain/dappbot-types/spec/user'; | ||
/** | ||
* Check whether the API's authData is | ||
* active, stale, or empty with one call. | ||
* The more specific functions rely on | ||
* this one. | ||
*/ | ||
authStatus() { | ||
return User.authStatus(this.authData); | ||
} | ||
/** | ||
* Helper to check the API's authData: only | ||
@@ -121,3 +131,3 @@ * `true` if the authData is both non-null | ||
hasActiveAuth():boolean { | ||
return User.authStatus(this.authData).isActive; | ||
return this.authStatus().isActive; | ||
} | ||
@@ -131,6 +141,3 @@ | ||
hasStaleAuth():boolean { | ||
return User.authStatus(this.authData).isStale; | ||
if (this.hasNoAuth()) return false; | ||
let expiryDate = Date.parse(this.authData.ExpiresAt); | ||
return expiryDate !== NaN && Date.now() > expiryDate; | ||
return this.authStatus().isStale; | ||
} | ||
@@ -144,3 +151,3 @@ | ||
hasNoAuth():boolean { | ||
return User.authStatus(this.authData).isEmpty; | ||
return this.authStatus().isEmpty; | ||
} | ||
@@ -147,0 +154,0 @@ } |
316492
0.09%1021
1.09%