@mondaydotcomorg/monday-authorization 3.5.1-fix-authorize-profile-picker-7481de0 → 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-e355942
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-ms-service.d.ts +95 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +362 -0
- package/dist/authorization-attributes-service.d.ts +26 -47
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +33 -171
- package/dist/authorization-attributes-sns-service.d.ts +91 -0
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/authorization-attributes-sns-service.js +217 -0
- 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/authorization-service.js +7 -34
- package/dist/base-attribute-assignment.d.ts +18 -0
- package/dist/base-attribute-assignment.d.ts.map +1 -0
- package/dist/base-attribute-assignment.js +43 -0
- package/dist/constants/sns.d.ts +12 -2
- package/dist/constants/sns.d.ts.map +1 -1
- package/dist/constants/sns.js +22 -2
- package/dist/entity-attribute-assignment.d.ts +14 -0
- package/dist/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/entity-attribute-assignment.js +24 -0
- package/dist/entity-attributes-constants.d.ts +7 -0
- package/dist/entity-attributes-constants.d.ts.map +1 -0
- package/dist/entity-attributes-constants.js +9 -0
- 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/authorization-attributes-ms-service.d.ts +95 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +360 -0
- package/dist/esm/authorization-attributes-service.d.ts +26 -47
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +33 -167
- package/dist/esm/authorization-attributes-sns-service.d.ts +91 -0
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-sns-service.mjs +211 -0
- 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/authorization-service.mjs +7 -34
- package/dist/esm/base-attribute-assignment.d.ts +18 -0
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/base-attribute-assignment.mjs +41 -0
- package/dist/esm/constants/sns.d.ts +12 -2
- package/dist/esm/constants/sns.d.ts.map +1 -1
- package/dist/esm/constants/sns.mjs +17 -3
- package/dist/esm/entity-attribute-assignment.d.ts +14 -0
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/entity-attribute-assignment.mjs +22 -0
- package/dist/esm/entity-attributes-constants.d.ts +7 -0
- package/dist/esm/entity-attributes-constants.d.ts.map +1 -0
- package/dist/esm/entity-attributes-constants.mjs +7 -0
- 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 +9 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/prometheus-service.d.ts +1 -2
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.d.ts +24 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/resource-attribute-assignment.mjs +34 -0
- package/dist/esm/resource-attributes-constants.d.ts +15 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- 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 +27 -12
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.mjs +6 -6
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +57 -0
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -0
- package/dist/esm/types/authorization-attributes-service.interface.mjs +1 -0
- package/dist/esm/types/general.d.ts +1 -2
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/validation.d.ts +45 -0
- package/dist/esm/utils/validation.d.ts.map +1 -0
- package/dist/esm/utils/validation.mjs +117 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/prometheus-service.d.ts +1 -2
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.d.ts +24 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/resource-attribute-assignment.js +36 -0
- package/dist/resource-attributes-constants.d.ts +15 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- 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 +27 -12
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.js +5 -5
- package/dist/types/authorization-attributes-service.interface.d.ts +57 -0
- package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -0
- package/dist/types/authorization-attributes-service.interface.js +1 -0
- package/dist/types/general.d.ts +1 -2
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +45 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +119 -0
- package/package.json +3 -2
- package/src/authorization-attributes-ms-service.ts +528 -0
- package/src/authorization-attributes-service.ts +35 -222
- package/src/authorization-attributes-sns-service.ts +312 -0
- package/src/authorization-middleware.ts +2 -2
- package/src/authorization-service.ts +15 -75
- package/src/base-attribute-assignment.ts +55 -0
- package/src/constants/sns.ts +19 -2
- package/src/entity-attribute-assignment.ts +21 -0
- package/src/entity-attributes-constants.ts +7 -0
- package/src/errors/argument-error.ts +7 -0
- package/src/index.ts +9 -0
- package/src/prometheus-service.ts +1 -2
- package/src/resource-attribute-assignment.ts +43 -0
- package/src/resource-attributes-constants.ts +35 -0
- package/src/testKit/index.ts +5 -5
- package/src/types/authorization-attributes-contracts.ts +36 -11
- package/src/types/authorization-attributes-service.interface.ts +100 -0
- package/src/types/general.ts +3 -2
- package/src/utils/validation.ts +114 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ResourceAttributeAssignment, ResourceAttributeOperation, EntityAttributeOperation } from './types/authorization-attributes-contracts';
|
|
2
|
+
import { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
3
|
+
import { Resource } from './types/general';
|
|
4
|
+
import { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
5
|
+
import { EntityType } from './types/authorization-attributes-contracts';
|
|
6
|
+
/**
|
|
7
|
+
* Service class for managing resource attributes asynchronously via SNS.
|
|
8
|
+
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AuthorizationAttributesSnsService implements IAuthorizationAttributesService {
|
|
11
|
+
private static LOG_TAG;
|
|
12
|
+
private resourceSnsArn;
|
|
13
|
+
private entitySnsArn;
|
|
14
|
+
/**
|
|
15
|
+
* Public constructor to create the AuthorizationAttributesSnsService instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Async function to upsert resource attributes using SNS.
|
|
20
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
21
|
+
* @param accountId The account ID
|
|
22
|
+
* @param appName App name of the calling app
|
|
23
|
+
* @param callerActionIdentifier Action identifier
|
|
24
|
+
* @param resourceAttributeAssignments Array of resource attribute assignments to upsert
|
|
25
|
+
* @return Promise with array of sent operations
|
|
26
|
+
*/
|
|
27
|
+
upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Async function to delete resource attributes using SNS.
|
|
30
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
31
|
+
* @param accountId The account ID
|
|
32
|
+
* @param appName App name of the calling app
|
|
33
|
+
* @param callerActionIdentifier Action identifier
|
|
34
|
+
* @param resource The resource (resourceType, resourceId)
|
|
35
|
+
* @param attributeKeys Array of attribute keys to delete
|
|
36
|
+
* @return Promise with array of sent operations
|
|
37
|
+
*/
|
|
38
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Async function to upsert entity attributes using SNS.
|
|
41
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
42
|
+
* @param accountId The account ID
|
|
43
|
+
* @param appName App name of the calling app
|
|
44
|
+
* @param callerActionIdentifier Action identifier
|
|
45
|
+
* @param entityAttributeAssignments Array of entity attribute assignments to upsert
|
|
46
|
+
* @return Promise with array of sent operations
|
|
47
|
+
*/
|
|
48
|
+
upsertEntityAttributes(accountId: number, entityAttributeAssignments: EntityAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Async function to delete entity attributes using SNS.
|
|
51
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
52
|
+
* @param accountId The account ID
|
|
53
|
+
* @param appName App name of the calling app
|
|
54
|
+
* @param callerActionIdentifier Action identifier
|
|
55
|
+
* @param entityType The entity type
|
|
56
|
+
* @param entityId The entity ID
|
|
57
|
+
* @param attributeKeys Array of attribute keys to delete
|
|
58
|
+
* @return Promise with array of sent operations
|
|
59
|
+
*/
|
|
60
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
63
|
+
* @param accountId
|
|
64
|
+
* @param appName - App name of the calling app
|
|
65
|
+
* @param callerActionIdentifier - action identifier
|
|
66
|
+
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
67
|
+
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
68
|
+
* */
|
|
69
|
+
updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeOperation[]): Promise<ResourceAttributeOperation[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
72
|
+
* @param accountId
|
|
73
|
+
* @param appName - App name of the calling app
|
|
74
|
+
* @param callerActionIdentifier - action identifier
|
|
75
|
+
* @param entityAttributeOperations - Array of operations to do on entity attributes.
|
|
76
|
+
* @return {Promise<EntityAttributeOperation[]>} Array of sent operations
|
|
77
|
+
* */
|
|
78
|
+
updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributeOperation[]): Promise<EntityAttributeOperation[]>;
|
|
79
|
+
private sendSingleSnsMessage;
|
|
80
|
+
private static getSnsTopicArn;
|
|
81
|
+
/**
|
|
82
|
+
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
83
|
+
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
84
|
+
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
85
|
+
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
86
|
+
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
87
|
+
* @return {Promise<boolean>} - true if succeeded
|
|
88
|
+
*/
|
|
89
|
+
asyncResourceAttributesHealthCheck(): Promise<boolean>;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=authorization-attributes-sns-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAe3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,+BAA+B;IACvF,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;;IAMH;;;;;;;;OAQG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,EAC3D,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAWxC;;;;;;;;;OASG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAgBxC;;;;;;;;OAQG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,yBAAyB,EAAE,EACvD,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;;;;OAUG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;UAOM;IACA,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,0BAA0B,EAAE,GACxD,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAoBxC;;;;;;;UAOM;IACA,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC;YAoBxB,oBAAoB;IA2BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import chunk from 'lodash/chunk.js';
|
|
2
|
+
import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
|
|
3
|
+
import { logger } from './authorization-internal-service.mjs';
|
|
4
|
+
import { SnsTopicType, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME } from './constants/sns.mjs';
|
|
5
|
+
import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Service class for managing resource attributes asynchronously via SNS.
|
|
9
|
+
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
10
|
+
*/
|
|
11
|
+
class AuthorizationAttributesSnsService {
|
|
12
|
+
static LOG_TAG = 'authorization_attributes';
|
|
13
|
+
resourceSnsArn;
|
|
14
|
+
entitySnsArn;
|
|
15
|
+
/**
|
|
16
|
+
* Public constructor to create the AuthorizationAttributesSnsService instance.
|
|
17
|
+
*/
|
|
18
|
+
constructor() {
|
|
19
|
+
this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
|
|
20
|
+
this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Async function to upsert resource attributes using SNS.
|
|
24
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
25
|
+
* @param accountId The account ID
|
|
26
|
+
* @param appName App name of the calling app
|
|
27
|
+
* @param callerActionIdentifier Action identifier
|
|
28
|
+
* @param resourceAttributeAssignments Array of resource attribute assignments to upsert
|
|
29
|
+
* @return Promise with array of sent operations
|
|
30
|
+
*/
|
|
31
|
+
async upsertResourceAttributes(accountId, resourceAttributeAssignments, appName, callerActionIdentifier) {
|
|
32
|
+
if (!appName || !callerActionIdentifier) {
|
|
33
|
+
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
34
|
+
}
|
|
35
|
+
const operations = resourceAttributeAssignments.map(assignment => ({
|
|
36
|
+
...assignment,
|
|
37
|
+
operationType: AttributeOperation.UPSERT,
|
|
38
|
+
}));
|
|
39
|
+
return this.updateResourceAttributes(accountId, appName, callerActionIdentifier, operations);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Async function to delete resource attributes using SNS.
|
|
43
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
44
|
+
* @param accountId The account ID
|
|
45
|
+
* @param appName App name of the calling app
|
|
46
|
+
* @param callerActionIdentifier Action identifier
|
|
47
|
+
* @param resource The resource (resourceType, resourceId)
|
|
48
|
+
* @param attributeKeys Array of attribute keys to delete
|
|
49
|
+
* @return Promise with array of sent operations
|
|
50
|
+
*/
|
|
51
|
+
async deleteResourceAttributes(accountId, resource, attributeKeys, appName, callerActionIdentifier) {
|
|
52
|
+
if (!appName || !callerActionIdentifier) {
|
|
53
|
+
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
54
|
+
}
|
|
55
|
+
const operations = attributeKeys.map(key => ({
|
|
56
|
+
resourceType: resource.type,
|
|
57
|
+
resourceId: resource.id,
|
|
58
|
+
key,
|
|
59
|
+
operationType: AttributeOperation.DELETE,
|
|
60
|
+
}));
|
|
61
|
+
return this.updateResourceAttributes(accountId, appName, callerActionIdentifier, operations);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Async function to upsert entity attributes using SNS.
|
|
65
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
66
|
+
* @param accountId The account ID
|
|
67
|
+
* @param appName App name of the calling app
|
|
68
|
+
* @param callerActionIdentifier Action identifier
|
|
69
|
+
* @param entityAttributeAssignments Array of entity attribute assignments to upsert
|
|
70
|
+
* @return Promise with array of sent operations
|
|
71
|
+
*/
|
|
72
|
+
async upsertEntityAttributes(accountId, entityAttributeAssignments, appName, callerActionIdentifier) {
|
|
73
|
+
if (!appName || !callerActionIdentifier) {
|
|
74
|
+
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
75
|
+
}
|
|
76
|
+
const operations = entityAttributeAssignments.map(assignment => {
|
|
77
|
+
return {
|
|
78
|
+
entityId: assignment.entityId,
|
|
79
|
+
entityType: assignment.entityType,
|
|
80
|
+
key: assignment.attributeKey,
|
|
81
|
+
value: assignment.attributeValue,
|
|
82
|
+
operationType: AttributeOperation.UPSERT,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
return this.updateEntityAttributes(accountId, appName, callerActionIdentifier, operations);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Async function to delete entity attributes using SNS.
|
|
89
|
+
* Sends the updates request to SNS and returns before the change actually took place.
|
|
90
|
+
* @param accountId The account ID
|
|
91
|
+
* @param appName App name of the calling app
|
|
92
|
+
* @param callerActionIdentifier Action identifier
|
|
93
|
+
* @param entityType The entity type
|
|
94
|
+
* @param entityId The entity ID
|
|
95
|
+
* @param attributeKeys Array of attribute keys to delete
|
|
96
|
+
* @return Promise with array of sent operations
|
|
97
|
+
*/
|
|
98
|
+
async deleteEntityAttributes(accountId, entityType, entityId, attributeKeys, appName, callerActionIdentifier) {
|
|
99
|
+
if (!appName || !callerActionIdentifier) {
|
|
100
|
+
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
101
|
+
}
|
|
102
|
+
const operations = attributeKeys.map(key => ({
|
|
103
|
+
entityType: entityType,
|
|
104
|
+
entityId,
|
|
105
|
+
key,
|
|
106
|
+
operationType: AttributeOperation.DELETE,
|
|
107
|
+
}));
|
|
108
|
+
return this.updateEntityAttributes(accountId, appName, callerActionIdentifier, operations);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
112
|
+
* @param accountId
|
|
113
|
+
* @param appName - App name of the calling app
|
|
114
|
+
* @param callerActionIdentifier - action identifier
|
|
115
|
+
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
116
|
+
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
117
|
+
* */
|
|
118
|
+
async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
|
|
119
|
+
const topicArn = this.resourceSnsArn;
|
|
120
|
+
const sendToSnsPromises = [];
|
|
121
|
+
const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
|
|
122
|
+
for (const operationsChunk of operationChucks) {
|
|
123
|
+
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async update: failed to send operations to SNS'));
|
|
124
|
+
}
|
|
125
|
+
return (await Promise.all(sendToSnsPromises)).flat();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
129
|
+
* @param accountId
|
|
130
|
+
* @param appName - App name of the calling app
|
|
131
|
+
* @param callerActionIdentifier - action identifier
|
|
132
|
+
* @param entityAttributeOperations - Array of operations to do on entity attributes.
|
|
133
|
+
* @return {Promise<EntityAttributeOperation[]>} Array of sent operations
|
|
134
|
+
* */
|
|
135
|
+
async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperations) {
|
|
136
|
+
const topicArn = this.entitySnsArn;
|
|
137
|
+
const sendToSnsPromises = [];
|
|
138
|
+
const operationChucks = chunk(entityAttributeOperations, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
|
|
139
|
+
for (const operationsChunk of operationChucks) {
|
|
140
|
+
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async update: failed to send operations to SNS'));
|
|
141
|
+
}
|
|
142
|
+
return (await Promise.all(sendToSnsPromises)).flat();
|
|
143
|
+
}
|
|
144
|
+
async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
|
|
145
|
+
const payload = {
|
|
146
|
+
kind,
|
|
147
|
+
payload: {
|
|
148
|
+
accountId: accountId,
|
|
149
|
+
callerAppName: appName,
|
|
150
|
+
callerActionIdentifier: callerActionIdentifier,
|
|
151
|
+
operations: operations,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
try {
|
|
155
|
+
await sendToSns(payload, topicArn);
|
|
156
|
+
return operations;
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
static getSnsTopicArn(type) {
|
|
164
|
+
let envVarName;
|
|
165
|
+
let devTestName;
|
|
166
|
+
switch (type) {
|
|
167
|
+
case SnsTopicType.ENTITY:
|
|
168
|
+
envVarName = ENTITY_SNS_ARN_ENV_VAR_NAME;
|
|
169
|
+
devTestName = ENTITY_SNS_DEV_TEST_NAME;
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
// Default to resource SNS constants
|
|
173
|
+
envVarName = RESOURCE_SNS_ARN_ENV_VAR_NAME;
|
|
174
|
+
devTestName = RESOURCE_SNS_DEV_TEST_NAME;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
const arnFromEnv = process.env[envVarName];
|
|
178
|
+
if (arnFromEnv) {
|
|
179
|
+
return arnFromEnv;
|
|
180
|
+
}
|
|
181
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
182
|
+
return devTestName;
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`Unable to get ${type} sns topic arn from env variable`);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
188
|
+
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
189
|
+
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
190
|
+
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
191
|
+
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
192
|
+
* @return {Promise<boolean>} - true if succeeded
|
|
193
|
+
*/
|
|
194
|
+
async asyncResourceAttributesHealthCheck() {
|
|
195
|
+
try {
|
|
196
|
+
const requestedTopicArn = this.resourceSnsArn;
|
|
197
|
+
const attributes = await getTopicAttributes(requestedTopicArn);
|
|
198
|
+
const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
|
|
199
|
+
if (!isHealthy) {
|
|
200
|
+
logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
|
|
201
|
+
}
|
|
202
|
+
return isHealthy;
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { AuthorizationAttributesSnsService };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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: string, 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,
|
|
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;AACpG,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 {
|
|
3
|
+
import { 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: string): 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: string): 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,
|
|
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;AAGrF,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"}
|
|
@@ -94,33 +94,15 @@ class AuthorizationService {
|
|
|
94
94
|
logger.error({ tag: 'authorization-service' }, 'AuthorizationService: igniteClient is not set, failing request');
|
|
95
95
|
throw new Error('AuthorizationService: igniteClient is not set, failing request');
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
logger.error({ tag: 'auth-debug', accountId, userId, appName, allowedProfiles, isAllowedProfile }, 'AuthorizationService.getProfile: checking allowed profiles');
|
|
100
|
-
if (isAllowedProfile) {
|
|
101
|
-
const profile = getProfile();
|
|
102
|
-
logger.error({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via allowed profiles');
|
|
103
|
-
return profile;
|
|
97
|
+
if (this.igniteClient.configuration.getObjectValue(ALLOWED_SDK_PLATFORM_PROFILES_KEY, []).includes(appName)) {
|
|
98
|
+
return getProfile();
|
|
104
99
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
accountId,
|
|
111
|
-
userId,
|
|
112
|
-
appName,
|
|
113
|
-
inReleaseProfiles,
|
|
114
|
-
isInReleaseProfile,
|
|
115
|
-
isFeatureFlagReleased,
|
|
116
|
-
featureFlag: PLATFORM_PROFILE_RELEASE_FF,
|
|
117
|
-
}, 'AuthorizationService.getProfile: checking feature flag release');
|
|
118
|
-
if (isInReleaseProfile && isFeatureFlagReleased) {
|
|
119
|
-
const profile = getProfile();
|
|
120
|
-
logger.error({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via feature flag release');
|
|
121
|
-
return profile;
|
|
100
|
+
if (this.igniteClient.configuration
|
|
101
|
+
.getObjectValue(IN_RELEASE_SDK_PLATFORM_PROFILES_KEY, [])
|
|
102
|
+
.includes(appName) &&
|
|
103
|
+
this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId })) {
|
|
104
|
+
return getProfile();
|
|
122
105
|
}
|
|
123
|
-
logger.error({ tag: 'auth-debug', accountId, userId, appName, profile: PlatformProfile.APP }, 'AuthorizationService.getProfile: selected default APP profile');
|
|
124
106
|
return PlatformProfile.APP;
|
|
125
107
|
}
|
|
126
108
|
static async canActionInScopeMultiple(accountId, userId, scopedActions) {
|
|
@@ -128,24 +110,15 @@ class AuthorizationService {
|
|
|
128
110
|
return [];
|
|
129
111
|
}
|
|
130
112
|
const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
|
|
131
|
-
logger.error({
|
|
132
|
-
tag: 'auth-debug',
|
|
133
|
-
accountId,
|
|
134
|
-
userId,
|
|
135
|
-
shouldNavigateToGraph,
|
|
136
|
-
featureFlag: NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF,
|
|
137
|
-
}, 'AuthorizationService.canActionInScopeMultiple: determining which API flow to use');
|
|
138
113
|
const startTime = performance.now();
|
|
139
114
|
let scopedActionResponseObjects;
|
|
140
115
|
let apiType;
|
|
141
116
|
if (shouldNavigateToGraph) {
|
|
142
117
|
apiType = 'graph';
|
|
143
|
-
logger.error({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using graph API flow');
|
|
144
118
|
scopedActionResponseObjects = await this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
145
119
|
}
|
|
146
120
|
else {
|
|
147
121
|
apiType = 'platform';
|
|
148
|
-
logger.error({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using platform API flow');
|
|
149
122
|
const profile = this.getProfile(accountId, userId);
|
|
150
123
|
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
151
124
|
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for attribute assignments (Resource or Entity)
|
|
3
|
+
* Provides common validation and functionality
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseAttributeAssignment<TId extends number, TType extends string> {
|
|
6
|
+
readonly id: TId;
|
|
7
|
+
readonly type: TType;
|
|
8
|
+
readonly attributeKey: string;
|
|
9
|
+
readonly attributeValue: string;
|
|
10
|
+
constructor(id: TId, type: string, attributeKey: string, attributeValue: string, validTypes: readonly string[], idFieldName: string, typeFieldName: string);
|
|
11
|
+
/**
|
|
12
|
+
* Compares two assignments for equality
|
|
13
|
+
* @param other Another assignment instance
|
|
14
|
+
* @returns true if all properties are equal
|
|
15
|
+
*/
|
|
16
|
+
equals(other: BaseAttributeAssignment<TId, TType>): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=base-attribute-assignment.d.ts.map
|
|
@@ -0,0 +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,GAAG,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM;IACpF,SAAgB,EAAE,EAAE,GAAG,CAAC;IACxB,SAAgB,IAAI,EAAE,KAAK,CAAC;IAC5B,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAGrC,EAAE,EAAE,GAAG,EACP,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM;IAmBvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO;CAW5D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ValidationUtils } from './utils/validation.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base class for attribute assignments (Resource or Entity)
|
|
5
|
+
* Provides common validation and functionality
|
|
6
|
+
*/
|
|
7
|
+
class BaseAttributeAssignment {
|
|
8
|
+
id;
|
|
9
|
+
type;
|
|
10
|
+
attributeKey;
|
|
11
|
+
attributeValue;
|
|
12
|
+
constructor(id, type, attributeKey, attributeValue, validTypes, idFieldName, typeFieldName) {
|
|
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');
|
|
21
|
+
this.id = id;
|
|
22
|
+
this.attributeKey = attributeKey;
|
|
23
|
+
this.attributeValue = attributeValue;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compares two assignments for equality
|
|
27
|
+
* @param other Another assignment instance
|
|
28
|
+
* @returns true if all properties are equal
|
|
29
|
+
*/
|
|
30
|
+
equals(other) {
|
|
31
|
+
if (!(other instanceof this.constructor)) {
|
|
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);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { BaseAttributeAssignment };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
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";
|
|
3
9
|
export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
|
|
10
|
+
export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
|
|
4
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
|
+
export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
|
|
14
|
+
export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
|
|
5
15
|
//# sourceMappingURL=sns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAGD,eAAO,MAAM,6BAA6B,0DAA0D,CAAC;AACrG,eAAO,MAAM,0BAA0B,0FACkD,CAAC;AAG1F,eAAO,MAAM,2BAA2B,wDAAwD,CAAC;AACjG,eAAO,MAAM,wBAAwB,wFACkD,CAAC;AACxF,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,mDAAmD,gCAAgC,CAAC;AACjG,eAAO,MAAM,oDAAoD,MAAM,CAAC;AACxE,eAAO,MAAM,kDAAkD,MAAM,CAAC;AAGtE,eAAO,MAAM,oBAAoB,0DAAgC,CAAC;AAClE,eAAO,MAAM,iBAAiB,0FAA6B,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var SnsTopicType;
|
|
2
|
+
(function (SnsTopicType) {
|
|
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';
|
|
3
12
|
const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
|
|
13
|
+
const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
|
|
4
14
|
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;
|
|
5
19
|
|
|
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 };
|
|
20
|
+
export { ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, SnsTopicType };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EntityType } from './entity-attributes-constants';
|
|
2
|
+
import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
3
|
+
export declare class EntityAttributeAssignment extends BaseAttributeAssignment<number, EntityType> {
|
|
4
|
+
readonly entityId: number;
|
|
5
|
+
readonly entityType: EntityType;
|
|
6
|
+
constructor(entityId: number, entityType: string, attributeKey: string, attributeValue: string);
|
|
7
|
+
/**
|
|
8
|
+
* Compares two assignments for equality
|
|
9
|
+
* @param other Another EntityAttributeAssignment instance
|
|
10
|
+
* @returns true if all properties are equal
|
|
11
|
+
*/
|
|
12
|
+
equals(other: EntityAttributeAssignment): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=entity-attribute-assignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;IACxF,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAK9F;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
2
|
+
import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
|
|
3
|
+
|
|
4
|
+
class EntityAttributeAssignment extends BaseAttributeAssignment {
|
|
5
|
+
entityId;
|
|
6
|
+
entityType;
|
|
7
|
+
constructor(entityId, entityType, attributeKey, attributeValue) {
|
|
8
|
+
super(entityId, entityType, attributeKey, attributeValue, Object.values(ENTITY_TYPES), 'entityId', 'entityType');
|
|
9
|
+
this.entityId = entityId;
|
|
10
|
+
this.entityType = this.type;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compares two assignments for equality
|
|
14
|
+
* @param other Another EntityAttributeAssignment instance
|
|
15
|
+
* @returns true if all properties are equal
|
|
16
|
+
*/
|
|
17
|
+
equals(other) {
|
|
18
|
+
return super.equals(other);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { EntityAttributeAssignment };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -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"}
|