kafka-ts 1.3.1-beta.0 → 1.3.1-beta.1

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.
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.oAuthAuthenticator = exports.oAuthBearer = void 0;
4
4
  const api_1 = require("../api");
5
+ const number_1 = require("../utils/number");
5
6
  const retry_1 = require("../utils/retry");
7
+ const MAX_INT = Math.pow(2, 31) - 1;
6
8
  const oAuthBearer = (getToken) => {
7
9
  return {
8
10
  mechanism: 'OAUTHBEARER',
@@ -23,7 +25,7 @@ const oAuthAuthenticator = ({ endpoint, clientId, clientSecret, refreshThreshold
23
25
  });
24
26
  const scheduleRefresh = () => {
25
27
  tokenPromise.then((token) => {
26
- const refreshInMs = (token.expires_in - refreshThresholdSeconds) * 1000;
28
+ const refreshInMs = (0, number_1.clamp)((token.expires_in - refreshThresholdSeconds) * 1000, 1, MAX_INT);
27
29
  setTimeout(() => {
28
30
  tokenPromise = createToken(endpoint, {
29
31
  grant_type: 'refresh_token',
@@ -0,0 +1 @@
1
+ export declare const clamp: (value: number, min: number, max: number) => number;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clamp = void 0;
4
+ const clamp = (value, min, max) => {
5
+ return Math.min(Math.max(value, min), max);
6
+ };
7
+ exports.clamp = clamp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-ts",
3
- "version": "1.3.1-beta.0",
3
+ "version": "1.3.1-beta.1",
4
4
  "main": "dist/index.js",
5
5
  "author": "Priit Käärd",
6
6
  "license": "MIT",