@mojaloop/security-bc-client-lib
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -36,5 +36,5 @@ import { AuthToken } from "./types"; | ||
private _haveValidToken; | ||
private _resetPrivDate; | ||
private _resetPrivateData; | ||
private _parseAndLoadAccessToken; | ||
private _requestToken; | ||
} |
@@ -37,2 +37,3 @@ /***** | ||
const types_1 = require("./types"); | ||
const JWKS_FETCH_KEYS_TIMEOUT_MS = 5 * 1000 * 60; // 5 mins | ||
class LoginHelper { | ||
@@ -58,2 +59,3 @@ constructor(authTokenUrl, logger) { | ||
this._tokenHelper = new token_helper_1.TokenHelper(`${url.protocol}//${url.hostname}:${url.port}${token_helper_1.DEFAULT_JWKS_PATH}`, this._logger); | ||
// fetch new jwks every 5 mins | ||
} | ||
@@ -70,2 +72,3 @@ get initialised() { | ||
setToken(accessToken) { | ||
this._resetPrivateData(); | ||
this._authMode = "PROVIDED_TOKEN"; | ||
@@ -76,2 +79,3 @@ this._parseAndLoadAccessToken(accessToken); | ||
setUserCredentials(client_id, username, password) { | ||
this._resetPrivateData(); | ||
this._authMode = "USER_CREDS"; | ||
@@ -84,2 +88,3 @@ this._client_id = client_id; | ||
setAppCredentials(client_id, client_secret) { | ||
this._resetPrivateData(); | ||
this._authMode = "APP_CREDS"; | ||
@@ -97,2 +102,6 @@ this._client_id = client_id; | ||
this._tokenHelperNeedsInit = false; | ||
// schedule flag reset in JWKS_FETCH_KEYS_TIMEOUT_MS | ||
setTimeout(() => { | ||
this._tokenHelperNeedsInit = true; | ||
}, JWKS_FETCH_KEYS_TIMEOUT_MS); | ||
} | ||
@@ -124,3 +133,3 @@ if (await this._haveValidToken()) { | ||
} | ||
_resetPrivDate() { | ||
_resetPrivateData() { | ||
this._responseObj = null; | ||
@@ -157,3 +166,3 @@ this._decodedToken = null; | ||
// make sure old values are not kept | ||
this._resetPrivDate(); | ||
this._resetPrivateData(); | ||
let payload; | ||
@@ -160,0 +169,0 @@ if (this._authMode === "USER_CREDS") { |
{ | ||
"name": "@mojaloop/security-bc-client-lib", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "mojaloop security authentication and authorization client library", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
61822
892