@mondaydotcomorg/monday-authorization 3.5.0-feat-use-profile-for-graph-can-action-in-scope-f1451ab → 3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-c9e4cfc
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/dist/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +1 -0
- package/dist/authorization-attributes-ms-service.d.ts +37 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +232 -0
- package/dist/authorization-attributes-service.d.ts +45 -1
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +262 -0
- package/dist/clients/graph-api.d.ts.map +1 -1
- package/dist/clients/graph-api.js +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -4
- package/dist/errors/argument-error.d.ts +4 -0
- package/dist/errors/argument-error.d.ts.map +1 -0
- package/dist/errors/argument-error.js +11 -0
- package/dist/esm/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +1 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts +37 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +230 -0
- package/dist/esm/authorization-attributes-service.d.ts +45 -1
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +263 -1
- package/dist/esm/clients/graph-api.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.mjs +1 -2
- package/dist/esm/constants.d.ts +0 -3
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +1 -5
- package/dist/esm/errors/argument-error.d.ts +4 -0
- package/dist/esm/errors/argument-error.d.ts.map +1 -0
- package/dist/esm/errors/argument-error.mjs +9 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/resource-attribute-assignment.d.ts +25 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/resource-attribute-assignment.mjs +60 -0
- package/dist/esm/resource-attributes-constants.d.ts +25 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- package/dist/esm/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/resource-attribute-assignment.d.ts +25 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/resource-attribute-assignment.js +62 -0
- package/dist/resource-attributes-constants.d.ts +25 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- package/dist/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/attributions-service.ts +4 -0
- package/src/authorization-attributes-ms-service.ts +327 -0
- package/src/authorization-attributes-service.ts +325 -0
- package/src/clients/graph-api.ts +1 -2
- package/src/constants.ts +0 -4
- package/src/errors/argument-error.ts +8 -0
- package/src/index.ts +16 -0
- package/src/resource-attribute-assignment.ts +70 -0
- package/src/resource-attributes-constants.ts +27 -0
- package/src/types/authorization-attributes-contracts.ts +49 -3
|
@@ -2,7 +2,7 @@ import chunk from 'lodash/chunk.js';
|
|
|
2
2
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
|
|
4
4
|
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
5
|
-
import { logger } from './authorization-internal-service.mjs';
|
|
5
|
+
import { logger, AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
6
6
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
7
7
|
import { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND } from './constants/sns.mjs';
|
|
8
8
|
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
@@ -12,6 +12,8 @@ class AuthorizationAttributesService {
|
|
|
12
12
|
static API_PATHS = {
|
|
13
13
|
UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
|
|
14
14
|
DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
|
|
15
|
+
UPSERT_ENTITY_ATTRIBUTES: '/attributes/{accountId}/entity',
|
|
16
|
+
DELETE_ENTITY_ATTRIBUTES: '/attributes/{accountId}/entity/{entityType}/{entityId}',
|
|
15
17
|
};
|
|
16
18
|
httpClient;
|
|
17
19
|
fetchOptions;
|
|
@@ -175,6 +177,266 @@ class AuthorizationAttributesService {
|
|
|
175
177
|
return false;
|
|
176
178
|
}
|
|
177
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Validates resource attribute assignments array
|
|
182
|
+
*/
|
|
183
|
+
static validateResourceAttributeAssignments(assignments) {
|
|
184
|
+
if (!Array.isArray(assignments)) {
|
|
185
|
+
throw new Error('resourceAttributeAssignments must be an array');
|
|
186
|
+
}
|
|
187
|
+
if (assignments.length === 0) {
|
|
188
|
+
throw new Error('resourceAttributeAssignments must contain at least 1 item');
|
|
189
|
+
}
|
|
190
|
+
if (assignments.length > 100) {
|
|
191
|
+
throw new Error('resourceAttributeAssignments must contain at most 100 items');
|
|
192
|
+
}
|
|
193
|
+
for (let i = 0; i < assignments.length; i++) {
|
|
194
|
+
const assignment = assignments[i];
|
|
195
|
+
if (!assignment.resourceId || typeof assignment.resourceId !== 'number') {
|
|
196
|
+
throw new Error(`resourceAttributeAssignments[${i}].resourceId is required and must be a number`);
|
|
197
|
+
}
|
|
198
|
+
if (!assignment.resourceType || typeof assignment.resourceType !== 'string') {
|
|
199
|
+
throw new Error(`resourceAttributeAssignments[${i}].resourceType is required and must be a string`);
|
|
200
|
+
}
|
|
201
|
+
if (!assignment.key || typeof assignment.key !== 'string') {
|
|
202
|
+
throw new Error(`resourceAttributeAssignments[${i}].key is required and must be a string`);
|
|
203
|
+
}
|
|
204
|
+
if (assignment.value === undefined || typeof assignment.value !== 'string') {
|
|
205
|
+
throw new Error(`resourceAttributeAssignments[${i}].value is required and must be a string`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Validates entity attribute assignments array
|
|
211
|
+
*/
|
|
212
|
+
static validateEntityAttributeAssignments(assignments) {
|
|
213
|
+
if (!Array.isArray(assignments)) {
|
|
214
|
+
throw new Error('entityAttributeAssignments must be an array');
|
|
215
|
+
}
|
|
216
|
+
if (assignments.length === 0) {
|
|
217
|
+
throw new Error('entityAttributeAssignments must contain at least 1 item');
|
|
218
|
+
}
|
|
219
|
+
if (assignments.length > 100) {
|
|
220
|
+
throw new Error('entityAttributeAssignments must contain at most 100 items');
|
|
221
|
+
}
|
|
222
|
+
for (let i = 0; i < assignments.length; i++) {
|
|
223
|
+
const assignment = assignments[i];
|
|
224
|
+
if (!assignment.entityId || typeof assignment.entityId !== 'number') {
|
|
225
|
+
throw new Error(`entityAttributeAssignments[${i}].entityId is required and must be a number`);
|
|
226
|
+
}
|
|
227
|
+
if (!assignment.entityType || typeof assignment.entityType !== 'string') {
|
|
228
|
+
throw new Error(`entityAttributeAssignments[${i}].entityType is required and must be a string`);
|
|
229
|
+
}
|
|
230
|
+
if (!assignment.key || typeof assignment.key !== 'string') {
|
|
231
|
+
throw new Error(`entityAttributeAssignments[${i}].key is required and must be a string`);
|
|
232
|
+
}
|
|
233
|
+
if (assignment.value === undefined || typeof assignment.value !== 'string') {
|
|
234
|
+
throw new Error(`entityAttributeAssignments[${i}].value is required and must be a string`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Upsert resource attributes synchronously.
|
|
240
|
+
* Matches API endpoint: POST /attributes/:accountId/resource
|
|
241
|
+
* @param accountId The account ID
|
|
242
|
+
* @param resourceAttributeAssignments Array of ResourceAttributeAssignment objects (1-100 items)
|
|
243
|
+
* @returns Promise with response containing affected attributes
|
|
244
|
+
*/
|
|
245
|
+
static async upsertResourceAttributesSync(accountId, resourceAttributeAssignments) {
|
|
246
|
+
// Validate inputs
|
|
247
|
+
if (!Number.isInteger(accountId)) {
|
|
248
|
+
throw new Error(`accountId must be an integer, got: ${accountId}`);
|
|
249
|
+
}
|
|
250
|
+
AuthorizationAttributesService.validateResourceAttributeAssignments(resourceAttributeAssignments);
|
|
251
|
+
const httpClient = Api.getPart('httpClient');
|
|
252
|
+
if (!httpClient) {
|
|
253
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
254
|
+
}
|
|
255
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
256
|
+
const path = AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString());
|
|
257
|
+
try {
|
|
258
|
+
return await httpClient.fetch({
|
|
259
|
+
url: {
|
|
260
|
+
appName: APP_NAME,
|
|
261
|
+
path,
|
|
262
|
+
},
|
|
263
|
+
method: 'POST',
|
|
264
|
+
headers: {
|
|
265
|
+
'Content-Type': 'application/json',
|
|
266
|
+
...attributionHeaders,
|
|
267
|
+
},
|
|
268
|
+
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
269
|
+
}, {
|
|
270
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
271
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
if (err instanceof HttpFetcherError) {
|
|
276
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributesSync', err.status, err.message));
|
|
277
|
+
}
|
|
278
|
+
throw err;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Delete resource attributes synchronously.
|
|
283
|
+
* Matches API endpoint: DELETE /attributes/:accountId/resource/:resourceType/:resourceId
|
|
284
|
+
* @param accountId The account ID
|
|
285
|
+
* @param resourceType The resource type
|
|
286
|
+
* @param resourceId The resource ID
|
|
287
|
+
* @param keys Array of attribute keys to delete
|
|
288
|
+
* @returns Promise with response containing affected attributes
|
|
289
|
+
*/
|
|
290
|
+
static async deleteResourceAttributesSync(accountId, resourceType, resourceId, keys) {
|
|
291
|
+
// Validate inputs
|
|
292
|
+
if (!Number.isInteger(accountId)) {
|
|
293
|
+
throw new Error(`accountId must be an integer, got: ${accountId}`);
|
|
294
|
+
}
|
|
295
|
+
if (!resourceType || typeof resourceType !== 'string') {
|
|
296
|
+
throw new Error(`resourceType must be a string, got: ${typeof resourceType}`);
|
|
297
|
+
}
|
|
298
|
+
if (!Number.isInteger(resourceId)) {
|
|
299
|
+
throw new Error(`resourceId must be an integer, got: ${resourceId}`);
|
|
300
|
+
}
|
|
301
|
+
if (!Array.isArray(keys)) {
|
|
302
|
+
throw new Error('keys must be an array');
|
|
303
|
+
}
|
|
304
|
+
if (keys.length === 0) {
|
|
305
|
+
throw new Error('keys must contain at least 1 item');
|
|
306
|
+
}
|
|
307
|
+
const httpClient = Api.getPart('httpClient');
|
|
308
|
+
if (!httpClient) {
|
|
309
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
310
|
+
}
|
|
311
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
312
|
+
const path = AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
|
|
313
|
+
.replace('{resourceType}', resourceType)
|
|
314
|
+
.replace('{resourceId}', resourceId.toString());
|
|
315
|
+
try {
|
|
316
|
+
return await httpClient.fetch({
|
|
317
|
+
url: {
|
|
318
|
+
appName: APP_NAME,
|
|
319
|
+
path,
|
|
320
|
+
},
|
|
321
|
+
method: 'DELETE',
|
|
322
|
+
headers: {
|
|
323
|
+
'Content-Type': 'application/json',
|
|
324
|
+
...attributionHeaders,
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify({ keys }),
|
|
327
|
+
}, {
|
|
328
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
329
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
if (err instanceof HttpFetcherError) {
|
|
334
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributesSync', err.status, err.message));
|
|
335
|
+
}
|
|
336
|
+
throw err;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Upsert entity attributes synchronously.
|
|
341
|
+
* Matches API endpoint: POST /attributes/:accountId/entity
|
|
342
|
+
* @param accountId The account ID
|
|
343
|
+
* @param entityAttributeAssignments Array of EntityAttributeAssignment objects (1-100 items)
|
|
344
|
+
* @returns Promise with response containing affected attributes
|
|
345
|
+
*/
|
|
346
|
+
static async upsertEntityAttributesSync(accountId, entityAttributeAssignments) {
|
|
347
|
+
// Validate inputs
|
|
348
|
+
if (!Number.isInteger(accountId)) {
|
|
349
|
+
throw new Error(`accountId must be an integer, got: ${accountId}`);
|
|
350
|
+
}
|
|
351
|
+
AuthorizationAttributesService.validateEntityAttributeAssignments(entityAttributeAssignments);
|
|
352
|
+
const httpClient = Api.getPart('httpClient');
|
|
353
|
+
if (!httpClient) {
|
|
354
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
355
|
+
}
|
|
356
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
357
|
+
const path = AuthorizationAttributesService.API_PATHS.UPSERT_ENTITY_ATTRIBUTES.replace('{accountId}', accountId.toString());
|
|
358
|
+
try {
|
|
359
|
+
return await httpClient.fetch({
|
|
360
|
+
url: {
|
|
361
|
+
appName: APP_NAME,
|
|
362
|
+
path,
|
|
363
|
+
},
|
|
364
|
+
method: 'POST',
|
|
365
|
+
headers: {
|
|
366
|
+
'Content-Type': 'application/json',
|
|
367
|
+
...attributionHeaders,
|
|
368
|
+
},
|
|
369
|
+
body: JSON.stringify({ entityAttributeAssignments }),
|
|
370
|
+
}, {
|
|
371
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
372
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
catch (err) {
|
|
376
|
+
if (err instanceof HttpFetcherError) {
|
|
377
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('upsertEntityAttributesSync', err.status, err.message));
|
|
378
|
+
}
|
|
379
|
+
throw err;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Delete entity attributes synchronously.
|
|
384
|
+
* Matches API endpoint: DELETE /attributes/:accountId/entity/:entityType/:entityId
|
|
385
|
+
* @param accountId The account ID
|
|
386
|
+
* @param entityType The entity type
|
|
387
|
+
* @param entityId The entity ID
|
|
388
|
+
* @param keys Array of attribute keys to delete
|
|
389
|
+
* @returns Promise with response containing affected attributes
|
|
390
|
+
*/
|
|
391
|
+
static async deleteEntityAttributesSync(accountId, entityType, entityId, keys) {
|
|
392
|
+
// Validate inputs
|
|
393
|
+
if (!Number.isInteger(accountId)) {
|
|
394
|
+
throw new Error(`accountId must be an integer, got: ${accountId}`);
|
|
395
|
+
}
|
|
396
|
+
if (!entityType || typeof entityType !== 'string') {
|
|
397
|
+
throw new Error(`entityType must be a string, got: ${typeof entityType}`);
|
|
398
|
+
}
|
|
399
|
+
if (!Number.isInteger(entityId)) {
|
|
400
|
+
throw new Error(`entityId must be an integer, got: ${entityId}`);
|
|
401
|
+
}
|
|
402
|
+
if (!Array.isArray(keys)) {
|
|
403
|
+
throw new Error('keys must be an array');
|
|
404
|
+
}
|
|
405
|
+
if (keys.length === 0) {
|
|
406
|
+
throw new Error('keys must contain at least 1 item');
|
|
407
|
+
}
|
|
408
|
+
const httpClient = Api.getPart('httpClient');
|
|
409
|
+
if (!httpClient) {
|
|
410
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
411
|
+
}
|
|
412
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
413
|
+
const path = AuthorizationAttributesService.API_PATHS.DELETE_ENTITY_ATTRIBUTES.replace('{accountId}', accountId.toString())
|
|
414
|
+
.replace('{entityType}', entityType)
|
|
415
|
+
.replace('{entityId}', entityId.toString());
|
|
416
|
+
try {
|
|
417
|
+
return await httpClient.fetch({
|
|
418
|
+
url: {
|
|
419
|
+
appName: APP_NAME,
|
|
420
|
+
path,
|
|
421
|
+
},
|
|
422
|
+
method: 'DELETE',
|
|
423
|
+
headers: {
|
|
424
|
+
'Content-Type': 'application/json',
|
|
425
|
+
...attributionHeaders,
|
|
426
|
+
},
|
|
427
|
+
body: JSON.stringify({ keys }),
|
|
428
|
+
}, {
|
|
429
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
430
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
catch (err) {
|
|
434
|
+
if (err instanceof HttpFetcherError) {
|
|
435
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('deleteEntityAttributesSync', err.status, err.message));
|
|
436
|
+
}
|
|
437
|
+
throw err;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
178
440
|
}
|
|
179
441
|
|
|
180
442
|
export { AuthorizationAttributesService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B;;OAEG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAMxC,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAWjC"}
|
|
@@ -4,7 +4,7 @@ import { PermitTechnicalReason } from '../types/scoped-actions-contracts.mjs';
|
|
|
4
4
|
import { AuthorizationInternalService } from '../authorization-internal-service.mjs';
|
|
5
5
|
import { getAttributionsFromApi } from '../attributions-service.mjs';
|
|
6
6
|
import { scopeToResource } from '../utils/authorization.utils.mjs';
|
|
7
|
-
import { GRAPH_APP_NAME
|
|
7
|
+
import { GRAPH_APP_NAME } from '../constants.mjs';
|
|
8
8
|
import { handleApiError } from '../utils/api-error-handler.mjs';
|
|
9
9
|
|
|
10
10
|
const CAN_ACTION_IN_SCOPE_GRAPH_PATH = '/permissions/is-allowed';
|
|
@@ -63,7 +63,6 @@ class GraphApi {
|
|
|
63
63
|
url: {
|
|
64
64
|
appName: GRAPH_APP_NAME,
|
|
65
65
|
path: CAN_ACTION_IN_SCOPE_GRAPH_PATH,
|
|
66
|
-
profile: GraphProfile.PERMISSION,
|
|
67
66
|
},
|
|
68
67
|
method: 'POST',
|
|
69
68
|
headers: {
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
|
2
2
|
import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
export declare const APP_NAME = "authorization";
|
|
4
4
|
export declare const GRAPH_APP_NAME = "authorization-graph";
|
|
5
|
-
export declare enum GraphProfile {
|
|
6
|
-
PERMISSION = "authorization-graph-permission"
|
|
7
|
-
}
|
|
8
5
|
export declare const ERROR_MESSAGES: {
|
|
9
6
|
readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
|
|
10
7
|
readonly REQUEST_FAILED: (method: string, status: number, reason: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAUjE,CAAC"}
|
package/dist/esm/constants.mjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
const APP_NAME = 'authorization';
|
|
2
2
|
const GRAPH_APP_NAME = 'authorization-graph';
|
|
3
|
-
var GraphProfile;
|
|
4
|
-
(function (GraphProfile) {
|
|
5
|
-
GraphProfile["PERMISSION"] = "authorization-graph-permission";
|
|
6
|
-
})(GraphProfile || (GraphProfile = {}));
|
|
7
3
|
const ERROR_MESSAGES = {
|
|
8
4
|
HTTP_CLIENT_NOT_INITIALIZED: 'MondayAuthorization: HTTP client is not initialized',
|
|
9
5
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
@@ -20,4 +16,4 @@ const DEFAULT_FETCH_OPTIONS = {
|
|
|
20
16
|
},
|
|
21
17
|
};
|
|
22
18
|
|
|
23
|
-
export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES, GRAPH_APP_NAME
|
|
19
|
+
export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES, GRAPH_APP_NAME };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument-error.d.ts","sourceRoot":"","sources":["../../../src/errors/argument-error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAK5B"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare function init(options?: InitOptions): Promise<void>;
|
|
|
19
19
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
20
20
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
21
21
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
22
|
+
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
23
|
+
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
24
|
+
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
25
|
+
export { ArgumentError } from './errors/argument-error';
|
|
26
|
+
export { EntityAttributeAssignment, ResourceAttributeResponse, EntityAttributeResponse, ResourceType, EntityType, ResourceAttributeKeyType, EntityAttributeKeyType, CommonAttributeKey, ResourceAttributeKey, EntityAttributeKey, } from './types/authorization-attributes-contracts';
|
|
22
27
|
export { RolesService } from './roles-service';
|
|
23
28
|
export { MembershipsService } from './memberships';
|
|
24
29
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI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,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,6 +6,10 @@ import * as testKit_index from './testKit/index.mjs';
|
|
|
6
6
|
export { testKit_index as TestKit };
|
|
7
7
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
|
|
8
8
|
export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
|
|
9
|
+
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
|
|
10
|
+
export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
11
|
+
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
12
|
+
export { ArgumentError } from './errors/argument-error.mjs';
|
|
9
13
|
export { RolesService } from './roles-service.mjs';
|
|
10
14
|
export { MembershipsService } from './memberships.mjs';
|
|
11
15
|
export { RoleType } from './types/roles.mjs';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ResourceType } from './resource-attributes-constants';
|
|
2
|
+
export declare class ResourceAttributeAssignment {
|
|
3
|
+
readonly resourceId: number;
|
|
4
|
+
readonly resourceType: ResourceType;
|
|
5
|
+
readonly attributeKey: string;
|
|
6
|
+
readonly attributeValue: string;
|
|
7
|
+
constructor(resourceId: number, resourceType: string, attributeKey: string, attributeValue: string);
|
|
8
|
+
/**
|
|
9
|
+
* Converts the assignment to hash format with camelCase keys
|
|
10
|
+
* @returns Object with camelCase keys: { resourceId, resourceType, key, value }
|
|
11
|
+
*/
|
|
12
|
+
toH(): {
|
|
13
|
+
resourceId: number;
|
|
14
|
+
resourceType: string;
|
|
15
|
+
key: string;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Compares two assignments for equality
|
|
20
|
+
* @param other Another ResourceAttributeAssignment instance
|
|
21
|
+
* @returns true if all properties are equal
|
|
22
|
+
*/
|
|
23
|
+
equals(other: ResourceAttributeAssignment): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=resource-attribute-assignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/E,qBAAa,2BAA2B;IACtC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IA8BlG;;;OAGG;IACH,GAAG,IAAI;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAS/E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAWpD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
2
|
+
import { ArgumentError } from './errors/argument-error.mjs';
|
|
3
|
+
|
|
4
|
+
class ResourceAttributeAssignment {
|
|
5
|
+
resourceId;
|
|
6
|
+
resourceType;
|
|
7
|
+
attributeKey;
|
|
8
|
+
attributeValue;
|
|
9
|
+
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
10
|
+
// Validate resourceId
|
|
11
|
+
if (!Number.isInteger(resourceId)) {
|
|
12
|
+
throw new ArgumentError(`resourceId must be an integer, got: ${resourceId}`);
|
|
13
|
+
}
|
|
14
|
+
// Validate resourceType
|
|
15
|
+
const validResourceTypes = Object.values(RESOURCE_TYPES);
|
|
16
|
+
if (!validResourceTypes.includes(resourceType)) {
|
|
17
|
+
throw new ArgumentError(`resourceType must be one of [${validResourceTypes.join(', ')}], got: ${resourceType}`);
|
|
18
|
+
}
|
|
19
|
+
// Validate attributeKey
|
|
20
|
+
if (typeof attributeKey !== 'string') {
|
|
21
|
+
throw new ArgumentError(`attributeKey must be a string, got: ${typeof attributeKey}`);
|
|
22
|
+
}
|
|
23
|
+
// Validate attributeValue
|
|
24
|
+
if (typeof attributeValue !== 'string') {
|
|
25
|
+
throw new ArgumentError(`attributeValue must be a string, got: ${typeof attributeValue}`);
|
|
26
|
+
}
|
|
27
|
+
this.resourceId = resourceId;
|
|
28
|
+
this.resourceType = resourceType;
|
|
29
|
+
this.attributeKey = attributeKey;
|
|
30
|
+
this.attributeValue = attributeValue;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts the assignment to hash format with camelCase keys
|
|
34
|
+
* @returns Object with camelCase keys: { resourceId, resourceType, key, value }
|
|
35
|
+
*/
|
|
36
|
+
toH() {
|
|
37
|
+
return {
|
|
38
|
+
resourceId: this.resourceId,
|
|
39
|
+
resourceType: this.resourceType,
|
|
40
|
+
key: this.attributeKey,
|
|
41
|
+
value: this.attributeValue,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compares two assignments for equality
|
|
46
|
+
* @param other Another ResourceAttributeAssignment instance
|
|
47
|
+
* @returns true if all properties are equal
|
|
48
|
+
*/
|
|
49
|
+
equals(other) {
|
|
50
|
+
if (!(other instanceof ResourceAttributeAssignment)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return (this.resourceId === other.resourceId &&
|
|
54
|
+
this.resourceType === other.resourceType &&
|
|
55
|
+
this.attributeKey === other.attributeKey &&
|
|
56
|
+
this.attributeValue === other.attributeValue);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { ResourceAttributeAssignment };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const RESOURCE_TYPES: {
|
|
2
|
+
readonly ACCOUNT: "account";
|
|
3
|
+
readonly ACCOUNT_PRODUCT: "account_product";
|
|
4
|
+
readonly WORKSPACE: "workspace";
|
|
5
|
+
readonly BOARD: "board";
|
|
6
|
+
readonly ITEM: "item";
|
|
7
|
+
readonly TEAM: "team";
|
|
8
|
+
readonly OVERVIEW: "overview";
|
|
9
|
+
readonly DOCUMENT: "document";
|
|
10
|
+
readonly CRM: "crm";
|
|
11
|
+
};
|
|
12
|
+
export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
|
|
13
|
+
readonly ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
14
|
+
readonly ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: "enable_members_invite_from_non_auth_domain";
|
|
15
|
+
};
|
|
16
|
+
readonly WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
17
|
+
readonly IS_DEFAULT_WORKSPACE: "is_default_workspace";
|
|
18
|
+
};
|
|
19
|
+
readonly BOARD_RESOURCE_ATTRIBUTES: {
|
|
20
|
+
readonly IS_SYNCABLE_CHILD_ENTITY: "is_syncable_child_entity";
|
|
21
|
+
readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type ResourceType = typeof RESOURCE_TYPES[keyof typeof RESOURCE_TYPES];
|
|
25
|
+
//# sourceMappingURL=resource-attributes-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAWhC,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const RESOURCE_TYPES = {
|
|
2
|
+
ACCOUNT: 'account',
|
|
3
|
+
ACCOUNT_PRODUCT: 'account_product',
|
|
4
|
+
WORKSPACE: 'workspace',
|
|
5
|
+
BOARD: 'board',
|
|
6
|
+
ITEM: 'item',
|
|
7
|
+
TEAM: 'team',
|
|
8
|
+
OVERVIEW: 'overview',
|
|
9
|
+
DOCUMENT: 'document',
|
|
10
|
+
CRM: 'crm',
|
|
11
|
+
};
|
|
12
|
+
const RESOURCE_ATTRIBUTES_CONSTANTS = {
|
|
13
|
+
ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
14
|
+
ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: 'enable_members_invite_from_non_auth_domain',
|
|
15
|
+
},
|
|
16
|
+
WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
17
|
+
IS_DEFAULT_WORKSPACE: 'is_default_workspace',
|
|
18
|
+
},
|
|
19
|
+
BOARD_RESOURCE_ATTRIBUTES: {
|
|
20
|
+
IS_SYNCABLE_CHILD_ENTITY: 'is_syncable_child_entity',
|
|
21
|
+
SYSTEM_ENTITY_TYPE: 'system_entity_type',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES };
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
|
+
export type ResourceType = 'account' | 'account_product' | 'workspace' | 'board' | 'item' | 'team' | 'overview' | 'document' | 'crm';
|
|
3
|
+
export type EntityType = 'user' | 'team' | 'account';
|
|
4
|
+
export type CommonAttributeKey = string;
|
|
5
|
+
export type ResourceAttributeKey = string;
|
|
6
|
+
export type EntityAttributeKey = string;
|
|
7
|
+
export type ResourceAttributeKeyType = CommonAttributeKey | ResourceAttributeKey;
|
|
8
|
+
export type EntityAttributeKeyType = CommonAttributeKey | EntityAttributeKey;
|
|
2
9
|
export interface ResourceAttributeAssignment {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
key:
|
|
10
|
+
resourceId: number;
|
|
11
|
+
resourceType: ResourceType;
|
|
12
|
+
key: ResourceAttributeKeyType;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EntityAttributeAssignment {
|
|
16
|
+
entityId: number;
|
|
17
|
+
entityType: EntityType;
|
|
18
|
+
key: EntityAttributeKeyType;
|
|
6
19
|
value: string;
|
|
7
20
|
}
|
|
8
21
|
export interface ResourceAttributeResponse {
|
|
9
22
|
attributes: ResourceAttributeAssignment[];
|
|
10
23
|
}
|
|
24
|
+
export interface EntityAttributeResponse {
|
|
25
|
+
attributes: EntityAttributeAssignment[];
|
|
26
|
+
}
|
|
11
27
|
export interface ResourceAttributeDelete {
|
|
12
28
|
resourceType: Resource['type'];
|
|
13
29
|
resourceId: Resource['id'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,iBAAiB,GACjB,WAAW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MAAM,CAAC;CACtD;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,GAAG,gCAAgC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare function init(options?: InitOptions): Promise<void>;
|
|
|
19
19
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
20
20
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
21
21
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
22
|
+
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
23
|
+
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
24
|
+
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
25
|
+
export { ArgumentError } from './errors/argument-error';
|
|
26
|
+
export { EntityAttributeAssignment, ResourceAttributeResponse, EntityAttributeResponse, ResourceType, EntityType, ResourceAttributeKeyType, EntityAttributeKeyType, CommonAttributeKey, ResourceAttributeKey, EntityAttributeKey, } from './types/authorization-attributes-contracts';
|
|
22
27
|
export { RolesService } from './roles-service';
|
|
23
28
|
export { MembershipsService } from './memberships';
|
|
24
29
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,E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aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,10 @@ const metricsService = require('./metrics-service.js');
|
|
|
6
6
|
const testKit_index = require('./testKit/index.js');
|
|
7
7
|
const authorizationMiddleware = require('./authorization-middleware.js');
|
|
8
8
|
const authorizationAttributesService = require('./authorization-attributes-service.js');
|
|
9
|
+
const authorizationAttributesMsService = require('./authorization-attributes-ms-service.js');
|
|
10
|
+
const resourceAttributeAssignment = require('./resource-attribute-assignment.js');
|
|
11
|
+
const resourceAttributesConstants = require('./resource-attributes-constants.js');
|
|
12
|
+
const errors_argumentError = require('./errors/argument-error.js');
|
|
9
13
|
const rolesService = require('./roles-service.js');
|
|
10
14
|
const memberships = require('./memberships.js');
|
|
11
15
|
const types_roles = require('./types/roles.js');
|
|
@@ -44,6 +48,11 @@ exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationChec
|
|
|
44
48
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
45
49
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
46
50
|
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
51
|
+
exports.AuthorizationAttributesMsService = authorizationAttributesMsService.AuthorizationAttributesMsService;
|
|
52
|
+
exports.ResourceAttributeAssignment = resourceAttributeAssignment.ResourceAttributeAssignment;
|
|
53
|
+
exports.RESOURCE_ATTRIBUTES_CONSTANTS = resourceAttributesConstants.RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
54
|
+
exports.RESOURCE_TYPES = resourceAttributesConstants.RESOURCE_TYPES;
|
|
55
|
+
exports.ArgumentError = errors_argumentError.ArgumentError;
|
|
47
56
|
exports.RolesService = rolesService.RolesService;
|
|
48
57
|
exports.MembershipsService = memberships.MembershipsService;
|
|
49
58
|
Object.defineProperty(exports, 'RoleType', {
|