zek 14.2.65 → 14.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2020/zek.mjs CHANGED
@@ -1138,25 +1138,31 @@ class AuthService {
1138
1138
  }
1139
1139
  _starRefreshTokenTimer() {
1140
1140
  this._stopRefreshTokenTimer();
1141
- let user = this.user;
1141
+ let user = this._user;
1142
1142
  if (user && user.refreshTokenTime) {
1143
1143
  let timeout = user.refreshTokenTime.getTime() - Date.now(); // - (60 * 1000);
1144
- if (timeout < 0)
1145
- timeout = 0;
1146
- this._refreshTokenTimeout = setTimeout(() => {
1147
- if (this._onRefreshTokenSubject) {
1148
- this._onRefreshTokenSubject.next();
1149
- }
1150
- }, timeout);
1144
+ if (timeout < 0) {
1145
+ this._emitRefreshToken();
1146
+ }
1147
+ const minRefreshTime = 60000; //1 min;
1148
+ if (timeout < minRefreshTime) {
1149
+ timeout = minRefreshTime;
1150
+ }
1151
+ this._timerId = setInterval(this._emitRefreshToken, timeout);
1151
1152
  }
1152
1153
  }
1153
1154
  _stopRefreshTokenTimer() {
1154
- if (typeof this._refreshTokenTimeout === 'number') {
1155
- clearTimeout(this._refreshTokenTimeout);
1155
+ if (typeof this._timerId === 'number') {
1156
+ clearInterval(this._timerId);
1157
+ }
1158
+ }
1159
+ _emitRefreshToken() {
1160
+ if (this._onRefreshTokenSubject) {
1161
+ this._onRefreshTokenSubject.next();
1156
1162
  }
1157
1163
  }
1158
1164
  isAuthenticated() {
1159
- let expired = this.getExpired() || new Date(0);
1165
+ let expired = this.getExpired() || new Date(0); // if getExpired is null return min JS date
1160
1166
  const newValue = new Date() < expired;
1161
1167
  if (this._oldValueIsAuthenticated !== newValue) {
1162
1168
  this._oldValueIsAuthenticated = newValue;