@mondaydotcomorg/monday-authorization 1.1.9-featurebelkaauthz-sdk-update.2213 → 1.1.9-featurebelkaauthz-sdk-update.2215
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.
|
@@ -25,13 +25,10 @@ class AuthorizationAttributesService {
|
|
|
25
25
|
static upsertResourceAttributes(accountId, userId, resourceAttributeAssignments) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
28
|
+
const attributionHeaders = (0, authorization_service_1.getAttributionsFromApi)();
|
|
28
29
|
const response = yield (0, monday_fetch_1.fetch)(this.getResourceAttributesUrl(accountId), {
|
|
29
30
|
method: 'POST',
|
|
30
|
-
headers: {
|
|
31
|
-
Authorization: internalAuthToken,
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': (0, authorization_service_1.getCurrentAppName)(),
|
|
34
|
-
},
|
|
31
|
+
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json', 'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': (0, authorization_service_1.getCurrentAppName)() }, attributionHeaders),
|
|
35
32
|
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
36
33
|
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
37
34
|
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
@@ -52,13 +49,10 @@ class AuthorizationAttributesService {
|
|
|
52
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
50
|
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
54
51
|
const url = `${this.getResourceAttributesUrl(accountId)}/${resource.type}/${resource.id}`;
|
|
52
|
+
const attributionHeaders = (0, authorization_service_1.getAttributionsFromApi)();
|
|
55
53
|
const response = yield (0, monday_fetch_1.fetch)(url, {
|
|
56
54
|
method: 'DELETE',
|
|
57
|
-
headers: {
|
|
58
|
-
Authorization: internalAuthToken,
|
|
59
|
-
'Content-Type': 'application/json',
|
|
60
|
-
'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': (0, authorization_service_1.getCurrentAppName)(),
|
|
61
|
-
},
|
|
55
|
+
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json', 'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': (0, authorization_service_1.getCurrentAppName)() }, attributionHeaders),
|
|
62
56
|
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
63
57
|
body: JSON.stringify({ keys: attributeKeys }),
|
|
64
58
|
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
@@ -9,10 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getCurrentAppName = exports.AuthorizationService = exports.setRedisClient = exports.setRequestFetchOptions = void 0;
|
|
12
|
+
exports.getAttributionsFromApi = exports.getAttributions = exports.getCurrentAppName = exports.AuthorizationService = exports.setRedisClient = exports.setRequestFetchOptions = void 0;
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const perf_hooks_1 = require("perf_hooks");
|
|
15
15
|
const monday_fetch_1 = require("@mondaydotcomorg/monday-fetch");
|
|
16
|
+
const trident_backend_api_1 = require("@mondaydotcomorg/trident-backend-api");
|
|
16
17
|
const prometheus_service_1 = require("./prometheus-service");
|
|
17
18
|
const authorization_internal_service_1 = require("./authorization-internal-service");
|
|
18
19
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
@@ -91,13 +92,10 @@ class AuthorizationService {
|
|
|
91
92
|
const scopedActionsPayload = scopedActions.map(scopedAction => {
|
|
92
93
|
return Object.assign(Object.assign({}, scopedAction), { scope: (0, lodash_1.mapKeys)(scopedAction.scope, (_, key) => (0, lodash_1.snakeCase)(key)) }); // for example: { workspaceId: 1 } => { workspace_id: 1 }
|
|
93
94
|
});
|
|
95
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
94
96
|
const response = yield (0, monday_fetch_1.fetch)(getCanActionsInScopesUrl(), {
|
|
95
97
|
method: 'POST',
|
|
96
|
-
headers: {
|
|
97
|
-
Authorization: internalAuthToken,
|
|
98
|
-
'Content-Type': 'application/json',
|
|
99
|
-
'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': getCurrentAppName(),
|
|
100
|
-
},
|
|
98
|
+
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json', 'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': getCurrentAppName() }, attributionHeaders),
|
|
101
99
|
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
102
100
|
body: JSON.stringify({
|
|
103
101
|
user_id: userId,
|
|
@@ -126,13 +124,10 @@ class AuthorizationService {
|
|
|
126
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
125
|
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
128
126
|
const startTime = perf_hooks_1.performance.now();
|
|
127
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
129
128
|
const response = yield (0, monday_fetch_1.fetch)(getAuthorizeUrl(), {
|
|
130
129
|
method: 'POST',
|
|
131
|
-
headers: {
|
|
132
|
-
Authorization: internalAuthToken,
|
|
133
|
-
'Content-Type': 'application/json',
|
|
134
|
-
'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': getCurrentAppName(),
|
|
135
|
-
},
|
|
130
|
+
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json', 'X-INTERNAL-CONTROLLER-CALLER-APP-NAME': getCurrentAppName() }, attributionHeaders),
|
|
136
131
|
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
137
132
|
body: JSON.stringify({
|
|
138
133
|
user_id: userId,
|
|
@@ -199,6 +194,25 @@ function getCurrentAppName() {
|
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
196
|
exports.getCurrentAppName = getCurrentAppName;
|
|
197
|
+
function getAttributions() {
|
|
198
|
+
var _a;
|
|
199
|
+
let attributions = (_a = getVariable('runtime_attributions/valid_attributes', { silent: true })) === null || _a === void 0 ? void 0 : _a.attributions;
|
|
200
|
+
return attributions;
|
|
201
|
+
}
|
|
202
|
+
exports.getAttributions = getAttributions;
|
|
203
|
+
function getAttributionsFromApi() {
|
|
204
|
+
const tridentContext = trident_backend_api_1.Api.getPart('context');
|
|
205
|
+
// @ts-expect-error not an error
|
|
206
|
+
const { runtimeAttributions } = tridentContext;
|
|
207
|
+
const attributionsHeaders = Object.fromEntries(runtimeAttributions === null || runtimeAttributions === void 0 ? void 0 : runtimeAttributions.buildOutgoingHeaders('HTTP_INTERNAL'));
|
|
208
|
+
const attributionHeadersInternal = {};
|
|
209
|
+
Object.keys(attributionsHeaders).forEach(function (key) {
|
|
210
|
+
attributionHeadersInternal[`${key}_belka_internal`] = attributionsHeaders[key];
|
|
211
|
+
});
|
|
212
|
+
// let attributions = getVariable('runtime_attributions/valid_attributes', { silent: true });
|
|
213
|
+
return attributionHeadersInternal;
|
|
214
|
+
}
|
|
215
|
+
exports.getAttributionsFromApi = getAttributionsFromApi;
|
|
202
216
|
function getVariable(key, options = { silent: false }) {
|
|
203
217
|
const result = tryJsonParse(getEnvVariable(key));
|
|
204
218
|
if (result === undefined && !options.silent) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "1.1.9-featurebelkaauthz-sdk-update.
|
|
3
|
+
"version": "1.1.9-featurebelkaauthz-sdk-update.2215+1bfb8b39a",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@mondaydotcomorg/monday-fetch": "^0.0.7",
|
|
13
13
|
"@mondaydotcomorg/monday-jwt": "^3.0.10",
|
|
14
14
|
"@mondaydotcomorg/monday-logger": "^3.0.10",
|
|
15
|
+
"@mondaydotcomorg/trident-backend-api": "^0.21.0",
|
|
15
16
|
"node-fetch": "^2.6.7",
|
|
16
17
|
"on-headers": "^1.0.2",
|
|
17
18
|
"ts-node": "^10.0.0"
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"files": [
|
|
33
34
|
"dist/"
|
|
34
35
|
],
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "1bfb8b39a050015f349ffafcd707b9aeb44dad91"
|
|
36
37
|
}
|