@mondaydotcomorg/monday-authorization 1.0.18 → 1.0.19

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.
@@ -38,9 +38,6 @@ const MondayLogger = __importStar(require("@mondaydotcomorg/monday-logger"));
38
38
  const monday_fetch_1 = __importDefault(require("@mondaydotcomorg/monday-fetch"));
39
39
  const prometheus_service_1 = require("./prometheus-service");
40
40
  const INTERNAL_APP_NAME = 'internal_ms';
41
- const URL = `${process.env.MONDAY_INTERNAL_URL}/internal_ms/authorization/authorize`;
42
- const IS_DEV_ENV = process.env.NODE_ENV === 'development';
43
- const REQUEST_TIMEOUT = IS_DEV_ENV ? 60000 : 2000;
44
41
  const logger = MondayLogger.getLogger();
45
42
  class AuthorizationService {
46
43
  static isAuthorized(accountId, userId, resources, action) {
@@ -48,10 +45,10 @@ class AuthorizationService {
48
45
  const internalAuthToken = monday_jwt_1.signAuthorizationHeader(INTERNAL_APP_NAME, accountId);
49
46
  const { authorizationObjects } = createAuthorizationParams(resources, action);
50
47
  const startTime = perf_hooks_1.performance.now();
51
- const response = yield monday_fetch_1.default(URL, {
48
+ const response = yield monday_fetch_1.default(getUrl(), {
52
49
  method: 'POST',
53
50
  headers: { Authorization: internalAuthToken, 'Content-Type': 'application/json' },
54
- timeout: REQUEST_TIMEOUT,
51
+ timeout: getRequestTimeout(),
55
52
  body: JSON.stringify({
56
53
  user_id: userId,
57
54
  authorize_request_objects: authorizationObjects,
@@ -109,3 +106,10 @@ function createAuthorizationParams(resources, action) {
109
106
  function logOnFetchFail(retries, error, response) {
110
107
  logger.error({ attempt: retries, error }, 'Authorization attempt failed due to network issues');
111
108
  }
109
+ function getUrl() {
110
+ return `${process.env.MONDAY_INTERNAL_URL}/internal_ms/authorization/authorize`;
111
+ }
112
+ function getRequestTimeout() {
113
+ const isDevEnv = process.env.NODE_ENV === 'development';
114
+ return isDevEnv ? 60000 : 2000;
115
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -31,5 +31,5 @@
31
31
  "files": [
32
32
  "dist/"
33
33
  ],
34
- "gitHead": "003096557ca719ae941f421a0960c170e74d5cc1"
34
+ "gitHead": "a10f09efb2cb77fabe017a3c661a165272a7d0a9"
35
35
  }