Comparing version 0.13.9 to 0.13.10
@@ -197,4 +197,41 @@ "use strict"; | ||
/** | ||
* Method to decode an access token | ||
* | ||
* @param {String} accessToken [Access Token to be decoded] | ||
* @return {Object} [decoded access token object] | ||
*/ | ||
decodeAccessToken (accessToken) { | ||
var tokenString; | ||
var bearerTypeAndToken = accessToken.split(" ") | ||
if (bearerTypeAndToken.length === 2) { | ||
tokenString = bearerTypeAndToken[1] | ||
} else if( bearerTypeAndToken.length === 1) { | ||
tokenString = bearerTypeAndToken[0] | ||
} else { | ||
throw new Error("Invalid token format") | ||
} | ||
var tokenParts = tokenString.split(".") | ||
if (tokenParts.length !== 3) { | ||
throw new Error("Invalid token format") | ||
} | ||
var encodedTokenInfo = tokenParts[1]; | ||
var tokenInfo = {}; | ||
try { | ||
var buf = new Buffer(encodedTokenInfo, "base64") | ||
tokenInfo = JSON.decode(buf.toString("utf8")) | ||
} catch(e) { | ||
console.log(e); | ||
throw new Error("Invalid token format") | ||
} | ||
return tokenInfo; | ||
} | ||
} | ||
module.exports = UsersUAA; | ||
module.exports = UsersUAA; |
{ | ||
"name": "cf-client", | ||
"version": "0.13.9", | ||
"version": "0.13.10", | ||
"description": "A Cloud Foundry Client for Node.js", | ||
@@ -5,0 +5,0 @@ "author": "Juan Antonio Breña Moral <bren@juanantonio.info>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123126
2861