@mondaydotcomorg/monday-authorization 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-a77c130 → 3.6.0-feat-shaime-support-entity-attributes-1-f58d933
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/authorization-attributes-service.d.ts +47 -26
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +171 -33
- package/dist/authorization-middleware.d.ts +2 -2
- package/dist/authorization-middleware.d.ts.map +1 -1
- package/dist/authorization-service.d.ts +3 -3
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/base-attribute-assignment.d.ts +6 -5
- package/dist/base-attribute-assignment.d.ts.map +1 -1
- package/dist/base-attribute-assignment.js +8 -17
- package/dist/constants/sns.d.ts +2 -12
- package/dist/constants/sns.d.ts.map +1 -1
- package/dist/constants/sns.js +2 -22
- package/dist/entity-attribute-assignment.d.ts +4 -8
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +5 -4
- package/dist/entity-attributes-constants.d.ts +6 -6
- package/dist/entity-attributes-constants.d.ts.map +1 -1
- package/dist/entity-attributes-constants.js +7 -5
- package/dist/errors/argument-error.d.ts.map +1 -1
- package/dist/errors/argument-error.js +0 -1
- package/dist/esm/authorization-attributes-service.d.ts +47 -26
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +167 -33
- package/dist/esm/authorization-middleware.d.ts +2 -2
- package/dist/esm/authorization-middleware.d.ts.map +1 -1
- package/dist/esm/authorization-service.d.ts +3 -3
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.d.ts +6 -5
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.mjs +4 -17
- package/dist/esm/constants/sns.d.ts +2 -12
- package/dist/esm/constants/sns.d.ts.map +1 -1
- package/dist/esm/constants/sns.mjs +3 -17
- package/dist/esm/entity-attribute-assignment.d.ts +4 -8
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +5 -4
- package/dist/esm/entity-attributes-constants.d.ts +6 -6
- package/dist/esm/entity-attributes-constants.d.ts.map +1 -1
- package/dist/esm/entity-attributes-constants.mjs +8 -6
- package/dist/esm/errors/argument-error.d.ts.map +1 -1
- package/dist/esm/errors/argument-error.mjs +0 -1
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +0 -7
- package/dist/esm/prometheus-service.d.ts +2 -1
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.d.ts +4 -8
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +3 -2
- package/dist/esm/resource-attributes-constants.d.ts +21 -11
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +17 -14
- package/dist/esm/testKit/index.d.ts +4 -4
- package/dist/esm/testKit/index.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +5 -4
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +7 -20
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +2 -1
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/assigment-schema.d.ts +29 -0
- package/dist/esm/utils/assigment-schema.d.ts.map +1 -0
- package/dist/esm/utils/assigment-schema.mjs +29 -0
- package/dist/esm/utils/validation.d.ts +13 -38
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +38 -97
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -15
- package/dist/prometheus-service.d.ts +2 -1
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.d.ts +4 -8
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +3 -2
- package/dist/resource-attributes-constants.d.ts +21 -11
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +16 -13
- package/dist/testKit/index.d.ts +4 -4
- package/dist/testKit/index.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +5 -4
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +7 -20
- package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/types/general.d.ts +2 -1
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/assigment-schema.d.ts +29 -0
- package/dist/utils/assigment-schema.d.ts.map +1 -0
- package/dist/utils/assigment-schema.js +36 -0
- package/dist/utils/validation.d.ts +13 -38
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +42 -97
- package/package.json +3 -3
- package/src/authorization-attributes-service.ts +222 -35
- package/src/authorization-middleware.ts +2 -2
- package/src/authorization-service.ts +4 -4
- package/src/base-attribute-assignment.ts +10 -35
- package/src/constants/sns.ts +2 -19
- package/src/entity-attribute-assignment.ts +9 -6
- package/src/entity-attributes-constants.ts +6 -6
- package/src/errors/argument-error.ts +0 -1
- package/src/index.ts +0 -9
- package/src/prometheus-service.ts +3 -1
- package/src/resource-attribute-assignment.ts +11 -13
- package/src/resource-attributes-constants.ts +15 -23
- package/src/testKit/index.ts +5 -5
- package/src/types/authorization-attributes-contracts.ts +5 -5
- package/src/types/authorization-attributes-service.interface.ts +12 -38
- package/src/types/general.ts +2 -3
- package/src/utils/assigment-schema.ts +29 -0
- package/src/utils/validation.ts +41 -92
- package/dist/authorization-attributes-ms-service.d.ts +0 -90
- package/dist/authorization-attributes-ms-service.d.ts.map +0 -1
- package/dist/authorization-attributes-ms-service.js +0 -352
- package/dist/authorization-attributes-sns-service.d.ts +0 -90
- package/dist/authorization-attributes-sns-service.d.ts.map +0 -1
- package/dist/authorization-attributes-sns-service.js +0 -217
- package/dist/esm/authorization-attributes-ms-service.d.ts +0 -90
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +0 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +0 -350
- package/dist/esm/authorization-attributes-sns-service.d.ts +0 -90
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +0 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +0 -211
- package/src/authorization-attributes-ms-service.ts +0 -514
- package/src/authorization-attributes-sns-service.ts +0 -312
|
@@ -1,33 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const service = new AuthorizationAttributesService();
|
|
9
|
-
*
|
|
10
|
-
* // Use direct operations
|
|
11
|
-
* await service.direct().upsertResourceAttributes(accountId, assignments);
|
|
12
|
-
*
|
|
13
|
-
* // Use SNS operations
|
|
14
|
-
* await service.sns().upsertResourceAttributes(accountId, assignments, appName, actionId);
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
1
|
+
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
+
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
+
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributeUpsertOperation } from './types/authorization-attributes-contracts';
|
|
4
|
+
import { Resource } from './types/general';
|
|
17
5
|
export declare class AuthorizationAttributesService {
|
|
18
|
-
private
|
|
19
|
-
private
|
|
6
|
+
private static LOG_TAG;
|
|
7
|
+
private static API_PATHS;
|
|
8
|
+
private httpClient;
|
|
9
|
+
private fetchOptions;
|
|
10
|
+
private snsArn;
|
|
20
11
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
12
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
13
|
+
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
14
|
+
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
24
15
|
*/
|
|
25
|
-
|
|
16
|
+
constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
|
|
26
17
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
18
|
+
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
19
|
+
* @param accountId
|
|
20
|
+
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
21
|
+
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
22
|
+
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
30
23
|
*/
|
|
31
|
-
|
|
24
|
+
upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<ResourceAttributeResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
27
|
+
* @param accountId
|
|
28
|
+
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
29
|
+
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
30
|
+
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
31
|
+
*/
|
|
32
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKeys: string[]): Promise<ResourceAttributeResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
35
|
+
* @param accountId
|
|
36
|
+
* @param appName - App name of the calling app
|
|
37
|
+
* @param callerActionIdentifier - action identifier
|
|
38
|
+
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
39
|
+
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
40
|
+
* */
|
|
41
|
+
updateResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeUpsertOperation[]): Promise<ResourceAttributeUpsertOperation[]>;
|
|
42
|
+
private sendSingleSnsMessage;
|
|
43
|
+
private static getSnsTopicArn;
|
|
44
|
+
/**
|
|
45
|
+
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
46
|
+
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
47
|
+
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
48
|
+
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
49
|
+
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
50
|
+
* @return {Promise<boolean>} - true if succeeded
|
|
51
|
+
*/
|
|
52
|
+
asyncResourceAttributesHealthCheck(): Promise<boolean>;
|
|
32
53
|
}
|
|
33
54
|
//# sourceMappingURL=authorization-attributes-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAY3C,qBAAa,8BAA8B;IACzC,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,MAAM,CAAC,SAAS,CAGb;IACX,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAqBnF;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,GAC1D,OAAO,CAAC,yBAAyB,CAAC;IA6BrC;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,CAAC;IAkCrC;;;;;;;UAOM;IACA,6BAA6B,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,gCAAgC,EAAE,GAC9D,OAAO,CAAC,gCAAgC,EAAE,CAAC;YAYhC,oBAAoB;IA4BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAW7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -1,45 +1,179 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import chunk from 'lodash/chunk.js';
|
|
2
|
+
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
3
|
+
import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
|
|
4
|
+
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
5
|
+
import { logger } from './authorization-internal-service.mjs';
|
|
6
|
+
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
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
|
+
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
3
9
|
|
|
4
|
-
/**
|
|
5
|
-
* Main service class for managing resource and entity attributes.
|
|
6
|
-
* Provides access to both direct (MS) and SNS operations.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const service = new AuthorizationAttributesService();
|
|
11
|
-
*
|
|
12
|
-
* // Use direct operations
|
|
13
|
-
* await service.direct().upsertResourceAttributes(accountId, assignments);
|
|
14
|
-
*
|
|
15
|
-
* // Use SNS operations
|
|
16
|
-
* await service.sns().upsertResourceAttributes(accountId, assignments, appName, actionId);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
10
|
class AuthorizationAttributesService {
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
static LOG_TAG = 'authorization_attributes';
|
|
12
|
+
static API_PATHS = {
|
|
13
|
+
UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
|
|
14
|
+
DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
|
|
15
|
+
};
|
|
16
|
+
httpClient;
|
|
17
|
+
fetchOptions;
|
|
18
|
+
snsArn;
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
20
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
21
|
+
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
22
|
+
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
24
|
+
constructor(httpClient, fetchOptions) {
|
|
25
|
+
if (!httpClient) {
|
|
26
|
+
httpClient = Api.getPart('httpClient');
|
|
27
|
+
if (!httpClient) {
|
|
28
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!fetchOptions) {
|
|
32
|
+
fetchOptions = DEFAULT_FETCH_OPTIONS;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fetchOptions = {
|
|
36
|
+
...DEFAULT_FETCH_OPTIONS,
|
|
37
|
+
...fetchOptions,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
this.httpClient = httpClient;
|
|
41
|
+
this.fetchOptions = fetchOptions;
|
|
42
|
+
this.snsArn = AuthorizationAttributesService.getSnsTopicArn();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
46
|
+
* @param accountId
|
|
47
|
+
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
48
|
+
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
49
|
+
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
50
|
+
*/
|
|
51
|
+
async upsertResourceAttributes(accountId, resourceAttributeAssignments) {
|
|
52
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
53
|
+
try {
|
|
54
|
+
return await this.httpClient.fetch({
|
|
55
|
+
url: {
|
|
56
|
+
appName: APP_NAME,
|
|
57
|
+
path: AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString()),
|
|
58
|
+
},
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
...attributionHeaders,
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
65
|
+
}, this.fetchOptions);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err instanceof HttpFetcherError) {
|
|
69
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributes', err.status, err.message));
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
30
72
|
}
|
|
31
|
-
return this._directService;
|
|
32
73
|
}
|
|
33
74
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
75
|
+
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
76
|
+
* @param accountId
|
|
77
|
+
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
78
|
+
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
79
|
+
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
37
80
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
81
|
+
async deleteResourceAttributes(accountId, resource, attributeKeys) {
|
|
82
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
83
|
+
if (!resource.id) {
|
|
84
|
+
throw new Error('Resource ID is required');
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return await this.httpClient.fetch({
|
|
88
|
+
url: {
|
|
89
|
+
appName: APP_NAME,
|
|
90
|
+
path: AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
|
|
91
|
+
.replace('{resourceType}', resource.type)
|
|
92
|
+
.replace('{resourceId}', resource.id.toString()),
|
|
93
|
+
},
|
|
94
|
+
method: 'DELETE',
|
|
95
|
+
headers: {
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
...attributionHeaders,
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify({ keys: attributeKeys }),
|
|
100
|
+
}, this.fetchOptions);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (err instanceof HttpFetcherError) {
|
|
104
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributes', err.status, err.message));
|
|
105
|
+
}
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
111
|
+
* @param accountId
|
|
112
|
+
* @param appName - App name of the calling app
|
|
113
|
+
* @param callerActionIdentifier - action identifier
|
|
114
|
+
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
115
|
+
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
116
|
+
* */
|
|
117
|
+
async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
|
|
118
|
+
const topicArn = this.snsArn;
|
|
119
|
+
const sendToSnsPromises = [];
|
|
120
|
+
const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
|
|
121
|
+
for (const operationsChunk of operationChucks) {
|
|
122
|
+
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
|
|
123
|
+
}
|
|
124
|
+
return (await Promise.all(sendToSnsPromises)).flat();
|
|
125
|
+
}
|
|
126
|
+
async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
|
|
127
|
+
const payload = {
|
|
128
|
+
kind: RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
|
|
129
|
+
payload: {
|
|
130
|
+
accountId: accountId,
|
|
131
|
+
callerAppName: appName,
|
|
132
|
+
callerActionIdentifier: callerActionIdentifier,
|
|
133
|
+
operations: operations,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
try {
|
|
137
|
+
await sendToSns(payload, topicArn);
|
|
138
|
+
return operations;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'Authorization resource attributes async update: failed to send operations to SNS');
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
static getSnsTopicArn() {
|
|
146
|
+
const arnFromEnv = process.env[SNS_ARN_ENV_VAR_NAME];
|
|
147
|
+
if (arnFromEnv) {
|
|
148
|
+
return arnFromEnv;
|
|
149
|
+
}
|
|
150
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
151
|
+
return SNS_DEV_TEST_NAME;
|
|
152
|
+
}
|
|
153
|
+
throw new Error('Unable to get sns topic arn from env variable');
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
157
|
+
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
158
|
+
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
159
|
+
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
160
|
+
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
161
|
+
* @return {Promise<boolean>} - true if succeeded
|
|
162
|
+
*/
|
|
163
|
+
async asyncResourceAttributesHealthCheck() {
|
|
164
|
+
try {
|
|
165
|
+
const requestedTopicArn = this.snsArn;
|
|
166
|
+
const attributes = await getTopicAttributes(requestedTopicArn);
|
|
167
|
+
const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
|
|
168
|
+
if (!isHealthy) {
|
|
169
|
+
logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service failed in health check');
|
|
170
|
+
}
|
|
171
|
+
return isHealthy;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service got error during health check');
|
|
175
|
+
return false;
|
|
41
176
|
}
|
|
42
|
-
return this._snsService;
|
|
43
177
|
}
|
|
44
178
|
}
|
|
45
179
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
|
|
1
|
+
import { Action, BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
|
|
2
2
|
import type { NextFunction } from 'express';
|
|
3
|
-
export declare function getAuthorizationMiddleware(action:
|
|
3
|
+
export declare function getAuthorizationMiddleware(action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
|
|
4
4
|
export declare function skipAuthorizationMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
5
5
|
export declare function authorizationCheckMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
6
6
|
export declare function defaultContextGetter(request: BaseRequest): Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,aAAa,CAAC,EAAE,aAAa,IAG3B,SAAS,WAAW,EACpB,UAAU,YAAY,EACtB,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAAC,CAajB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAGlH;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASnH;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAElE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
2
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
3
|
-
import { AuthorizationObject, AuthorizationParams, Resource } from './types/general';
|
|
3
|
+
import { Action, AuthorizationObject, AuthorizationParams, Resource } from './types/general';
|
|
4
4
|
import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
|
|
5
5
|
export interface AuthorizeResponse {
|
|
6
6
|
isAuthorized: boolean;
|
|
@@ -21,7 +21,7 @@ export declare class AuthorizationService {
|
|
|
21
21
|
* @deprecated use the second form with authorizationRequestObjects instead,
|
|
22
22
|
* support of this function will be dropped gradually
|
|
23
23
|
*/
|
|
24
|
-
static isAuthorized(accountId: number, userId: number, resources: Resource[], action:
|
|
24
|
+
static isAuthorized(accountId: number, userId: number, resources: Resource[], action: Action): Promise<AuthorizeResponse>;
|
|
25
25
|
static isAuthorized(accountId: number, userId: number, authorizationRequestObjects: AuthorizationObject[]): Promise<AuthorizeResponse>;
|
|
26
26
|
/**
|
|
27
27
|
* @deprecated - Please use Ignite instead: https://github.com/DaPulse/ignite-monorepo/blob/master/packages/ignite-sdk/README.md
|
|
@@ -40,5 +40,5 @@ export declare class AuthorizationService {
|
|
|
40
40
|
}
|
|
41
41
|
export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
|
|
42
42
|
export declare function setIgniteClient(): Promise<void>;
|
|
43
|
-
export declare function createAuthorizationParams(resources: Resource[], action:
|
|
43
|
+
export declare function createAuthorizationParams(resources: Resource[], action: Action): AuthorizationParams;
|
|
44
44
|
//# sourceMappingURL=authorization-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAe1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC,MAAM,KAAK,WAAW,GAK7B;IACD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAc;IAE1C,MAAM,CAAC,eAAe,IAAI,IAAI;IAK9B,MAAM,CAAC,WAAW,CAAC,MAAC;IACpB,MAAM,CAAC,sCAAsC,CAAC,EAAE,MAAM,CAAC;IACvD,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAEnC;;;OAGG;WACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC;WAEhB,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,2BAA2B,EAAE,mBAAmB,EAAE,GACjD,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;OAGG;WACU,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;IAM9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAsBZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* Base class for attribute assignments (Resource or Entity)
|
|
3
3
|
* Provides common validation and functionality
|
|
4
4
|
*/
|
|
5
|
-
export declare abstract class BaseAttributeAssignment<
|
|
6
|
-
readonly id:
|
|
7
|
-
readonly type:
|
|
5
|
+
export declare abstract class BaseAttributeAssignment<T, R> {
|
|
6
|
+
readonly id: number;
|
|
7
|
+
readonly type: T;
|
|
8
8
|
readonly attributeKey: string;
|
|
9
9
|
readonly attributeValue: string;
|
|
10
|
-
constructor(id:
|
|
10
|
+
constructor(id: number, type: T, attributeKey: string, attributeValue: string);
|
|
11
11
|
/**
|
|
12
12
|
* Compares two assignments for equality
|
|
13
13
|
* @param other Another assignment instance
|
|
14
14
|
* @returns true if all properties are equal
|
|
15
15
|
*/
|
|
16
|
-
equals(other: BaseAttributeAssignment<
|
|
16
|
+
equals(other: BaseAttributeAssignment<T, R>): boolean;
|
|
17
|
+
abstract toDataTransferObject(): R;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=base-attribute-assignment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,CAAC,EAAE,CAAC;IAChD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,CAAC,CAAC;IACxB,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAO7E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO;IAIrD,QAAQ,CAAC,oBAAoB,IAAI,CAAC;CACnC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isEqual from 'lodash/isEqual.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for attribute assignments (Resource or Entity)
|
|
@@ -9,16 +9,9 @@ class BaseAttributeAssignment {
|
|
|
9
9
|
type;
|
|
10
10
|
attributeKey;
|
|
11
11
|
attributeValue;
|
|
12
|
-
constructor(id, type, attributeKey, attributeValue
|
|
13
|
-
// Validate id
|
|
14
|
-
ValidationUtils.validateInteger(id, idFieldName);
|
|
15
|
-
// Validate type
|
|
16
|
-
this.type = ValidationUtils.validateEnum(type, validTypes, typeFieldName);
|
|
17
|
-
// Validate attributeKey
|
|
18
|
-
ValidationUtils.validateString(attributeKey, 'attributeKey');
|
|
19
|
-
// Validate attributeValue
|
|
20
|
-
ValidationUtils.validateString(attributeValue, 'attributeValue');
|
|
12
|
+
constructor(id, type, attributeKey, attributeValue) {
|
|
21
13
|
this.id = id;
|
|
14
|
+
this.type = type;
|
|
22
15
|
this.attributeKey = attributeKey;
|
|
23
16
|
this.attributeValue = attributeValue;
|
|
24
17
|
}
|
|
@@ -28,13 +21,7 @@ class BaseAttributeAssignment {
|
|
|
28
21
|
* @returns true if all properties are equal
|
|
29
22
|
*/
|
|
30
23
|
equals(other) {
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return (this.id === other.id &&
|
|
35
|
-
this.type === other.type &&
|
|
36
|
-
this.attributeKey === other.attributeKey &&
|
|
37
|
-
this.attributeValue === other.attributeValue);
|
|
24
|
+
return isEqual(this, other);
|
|
38
25
|
}
|
|
39
26
|
}
|
|
40
27
|
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
export declare enum SnsTopicType {
|
|
2
|
-
RESOURCE = "resource",
|
|
3
|
-
ENTITY = "entity"
|
|
4
|
-
}
|
|
5
|
-
export declare const RESOURCE_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
|
|
6
|
-
export declare const RESOURCE_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
|
|
7
|
-
export declare const ENTITY_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES";
|
|
8
|
-
export declare const ENTITY_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local";
|
|
9
|
-
export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
|
|
10
|
-
export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
|
|
11
|
-
export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
12
|
-
export declare const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
13
1
|
export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
|
|
14
2
|
export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
|
|
3
|
+
export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
|
|
4
|
+
export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
15
5
|
//# sourceMappingURL=sns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,0FAC2D,CAAC;AAC1F,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,oDAAoD,MAAM,CAAC"}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
SnsTopicType["RESOURCE"] = "resource";
|
|
4
|
-
SnsTopicType["ENTITY"] = "entity";
|
|
5
|
-
})(SnsTopicType || (SnsTopicType = {}));
|
|
6
|
-
// Resource SNS constants
|
|
7
|
-
const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
|
|
8
|
-
const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
|
|
9
|
-
// Entity SNS constants
|
|
10
|
-
const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
|
|
11
|
-
const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
|
|
1
|
+
const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
|
|
2
|
+
const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
|
|
12
3
|
const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
|
|
13
|
-
const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
|
|
14
4
|
const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
15
|
-
const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
16
|
-
// Legacy exports for backward compatibility
|
|
17
|
-
const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
|
|
18
|
-
const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
|
|
19
5
|
|
|
20
|
-
export {
|
|
6
|
+
export { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { EntityType } from './entity-attributes-constants';
|
|
2
2
|
import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
3
|
-
|
|
3
|
+
import { EntityAttributeAssignment as EntityAttributeAssignmentContract } from './types/authorization-attributes-contracts';
|
|
4
|
+
export declare class EntityAttributeAssignment extends BaseAttributeAssignment<EntityType, EntityAttributeAssignmentContract> {
|
|
4
5
|
readonly entityId: number;
|
|
5
6
|
readonly entityType: EntityType;
|
|
6
|
-
constructor(entityId: number, entityType:
|
|
7
|
-
toDataTransferObject():
|
|
8
|
-
entityId: number;
|
|
9
|
-
entityType: EntityType;
|
|
10
|
-
key: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
7
|
+
constructor(entityId: number, entityType: EntityType, key: string, value: string);
|
|
8
|
+
toDataTransferObject(): EntityAttributeAssignmentContract;
|
|
13
9
|
/**
|
|
14
10
|
* Compares two assignments for equality
|
|
15
11
|
* @param other Another EntityAttributeAssignment instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAG5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAOhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
2
1
|
import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
|
|
2
|
+
import { ValidationUtils } from './utils/validation.mjs';
|
|
3
3
|
|
|
4
4
|
class EntityAttributeAssignment extends BaseAttributeAssignment {
|
|
5
5
|
entityId;
|
|
6
6
|
entityType;
|
|
7
|
-
constructor(entityId, entityType,
|
|
8
|
-
|
|
7
|
+
constructor(entityId, entityType, key, value) {
|
|
8
|
+
ValidationUtils.validateEntityAssignment({ entityId, entityType, key, value });
|
|
9
|
+
super(entityId, entityType, key, value);
|
|
9
10
|
this.entityId = entityId;
|
|
10
|
-
this.entityType =
|
|
11
|
+
this.entityType = entityType;
|
|
11
12
|
}
|
|
12
13
|
toDataTransferObject() {
|
|
13
14
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
1
|
+
export declare enum EntityType {
|
|
2
|
+
User = "user",
|
|
3
|
+
Team = "team",
|
|
4
|
+
Account = "account"
|
|
5
|
+
}
|
|
6
|
+
export declare const ENTITY_TYPES: readonly EntityType[];
|
|
7
7
|
//# sourceMappingURL=entity-attributes-constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,YAAY,uBAA2C,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var EntityType;
|
|
2
|
+
(function (EntityType) {
|
|
3
|
+
EntityType["User"] = "user";
|
|
4
|
+
EntityType["Team"] = "team";
|
|
5
|
+
EntityType["Account"] = "account";
|
|
6
|
+
})(EntityType || (EntityType = {}));
|
|
7
|
+
const ENTITY_TYPES = Object.freeze(Object.values(EntityType));
|
|
6
8
|
|
|
7
|
-
export { ENTITY_TYPES };
|
|
9
|
+
export { ENTITY_TYPES, EntityType };
|
|
@@ -1 +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;
|
|
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;CAI5B"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -19,15 +19,6 @@ 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 { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service';
|
|
23
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
24
|
-
export { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
25
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
26
|
-
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
27
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
28
|
-
export { ENTITY_TYPES } from './entity-attributes-constants';
|
|
29
|
-
export { ArgumentError } from './errors/argument-error';
|
|
30
|
-
export type { EntityType } from './entity-attributes-constants';
|
|
31
22
|
export { RolesService } from './roles-service';
|
|
32
23
|
export { MembershipsService } from './memberships';
|
|
33
24
|
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,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,
|
|
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,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,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,13 +6,6 @@ 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 { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service.mjs';
|
|
10
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
|
|
11
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
12
|
-
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
13
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
|
|
14
|
-
export { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
15
|
-
export { ArgumentError } from './errors/argument-error.mjs';
|
|
16
9
|
export { RolesService } from './roles-service.mjs';
|
|
17
10
|
export { MembershipsService } from './memberships.mjs';
|
|
18
11
|
export { RoleType } from './types/roles.mjs';
|