@dudadev/ms-client-auth
Advanced tools
Comparing version 1.2.4 to 1.3.0
@@ -14,3 +14,4 @@ "use strict"; | ||
constructor({ | ||
autoAuthInterval | ||
autoAuthInterval, | ||
retries = 2 | ||
} = {}) { | ||
@@ -20,2 +21,4 @@ this._listeners = []; | ||
this._timeout = 0; | ||
this._errorRetries = retries; | ||
this._erroredCount = 0; | ||
@@ -28,2 +31,6 @@ if (autoAuthInterval > 0) { | ||
get token() { | ||
if (!this.authDetails) { | ||
return null; | ||
} | ||
return this.authDetails.value; | ||
@@ -43,5 +50,9 @@ } | ||
this._timeout = setTimeout(() => { | ||
this.authenticateServices(); | ||
if (this._erroredCount < this._errorRetries) { | ||
this.authenticateServices(); | ||
this._registerNextAuth(); | ||
this._registerNextAuth(); | ||
} else { | ||
clearTimeout(this._timeout); | ||
} | ||
}, this._interval); | ||
@@ -88,2 +99,4 @@ } | ||
_fetchAuthDetails() { | ||
var _this2 = this; | ||
return _asyncToGenerator(function* () { | ||
@@ -93,3 +106,9 @@ const response = yield window.fetch('/api/ms/auth', { | ||
}); | ||
return response.json(); | ||
if (response.ok) { | ||
return response.json(); | ||
} | ||
_this2._erroredCount++; | ||
return null; | ||
})(); | ||
@@ -101,7 +120,9 @@ } | ||
function create({ | ||
autoAuthInterval | ||
autoAuthInterval, | ||
retries | ||
} = {}) { | ||
return new AuthService({ | ||
autoAuthInterval | ||
autoAuthInterval, | ||
retries | ||
}); | ||
} |
{ | ||
"name": "@dudadev/ms-client-auth", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Client to authenticate Duda's microservices' clients", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
4976
93