@mondaydotcomorg/monday-authorization 3.5.0 → 3.5.1-feat-shaime-support-entity-attributes-in-authorization-sdk-d2be13e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +1 -0
- package/dist/authorization-attributes-ms-service.d.ts +67 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +256 -0
- package/dist/authorization-attributes-sns-service.d.ts +85 -0
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/authorization-attributes-sns-service.js +203 -0
- 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/clients/graph-api.d.ts.map +1 -1
- package/dist/clients/graph-api.js +1 -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/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/entity-attribute-assignment.d.ts +24 -0
- package/dist/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/entity-attribute-assignment.js +36 -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/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +1 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts +67 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +254 -0
- package/dist/esm/authorization-attributes-sns-service.d.ts +85 -0
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-sns-service.mjs +197 -0
- 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/clients/graph-api.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.mjs +2 -1
- 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/constants.d.ts +3 -0
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +5 -1
- package/dist/esm/entity-attribute-assignment.d.ts +24 -0
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/entity-attribute-assignment.mjs +34 -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 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +7 -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 +25 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- package/dist/esm/roles-service.d.ts +1 -1
- package/dist/esm/roles-service.mjs +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +36 -4
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.mjs +6 -1
- package/dist/esm/utils/path-utils.d.ts +8 -0
- package/dist/esm/utils/path-utils.d.ts.map +1 -0
- package/dist/esm/utils/path-utils.mjs +15 -0
- 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 +75 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- 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 +25 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- package/dist/roles-service.d.ts +1 -1
- package/dist/roles-service.js +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +36 -4
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.js +5 -0
- package/dist/utils/path-utils.d.ts +8 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +17 -0
- package/dist/utils/validation.d.ts +45 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +77 -0
- package/package.json +1 -1
- package/src/attributions-service.ts +4 -0
- package/src/authorization-attributes-ms-service.ts +400 -0
- package/src/authorization-attributes-sns-service.ts +290 -0
- package/src/base-attribute-assignment.ts +55 -0
- package/src/clients/graph-api.ts +2 -1
- package/src/constants/sns.ts +19 -2
- package/src/constants.ts +4 -0
- package/src/entity-attribute-assignment.ts +35 -0
- package/src/entity-attributes-constants.ts +7 -0
- package/src/errors/argument-error.ts +7 -0
- package/src/index.ts +18 -1
- package/src/resource-attribute-assignment.ts +43 -0
- package/src/resource-attributes-constants.ts +26 -0
- package/src/roles-service.ts +1 -1
- package/src/types/authorization-attributes-contracts.ts +56 -3
- package/src/utils/path-utils.ts +13 -0
- package/src/utils/validation.ts +77 -0
- package/dist/authorization-attributes-service.d.ts +0 -54
- package/dist/authorization-attributes-service.d.ts.map +0 -1
- package/dist/authorization-attributes-service.js +0 -186
- package/dist/esm/authorization-attributes-service.d.ts +0 -54
- package/dist/esm/authorization-attributes-service.d.ts.map +0 -1
- package/dist/esm/authorization-attributes-service.mjs +0 -180
- package/src/authorization-attributes-service.ts +0 -234
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ArgumentError } from '../errors/argument-error';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for common validation operations
|
|
5
|
+
*/
|
|
6
|
+
export class ValidationUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Validates that a value is an integer
|
|
9
|
+
* @param value The value to validate
|
|
10
|
+
* @param fieldName The name of the field for error messages
|
|
11
|
+
* @throws ArgumentError if value is not an integer
|
|
12
|
+
*/
|
|
13
|
+
static validateInteger(value: any, fieldName: string): void {
|
|
14
|
+
if (!Number.isInteger(value)) {
|
|
15
|
+
throw new ArgumentError(`${fieldName} must be an integer, got: ${value}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Validates that a value is a string
|
|
21
|
+
* @param value The value to validate
|
|
22
|
+
* @param fieldName The name of the field for error messages
|
|
23
|
+
* @throws ArgumentError if value is not a string
|
|
24
|
+
*/
|
|
25
|
+
static validateString(value: any, fieldName: string): void {
|
|
26
|
+
if (typeof value !== 'string') {
|
|
27
|
+
throw new ArgumentError(`${fieldName} must be a string, got: ${typeof value}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Validates that a value is an array and optionally checks minimum length
|
|
33
|
+
* @param value The value to validate
|
|
34
|
+
* @param fieldName The name of the field for error messages
|
|
35
|
+
* @param minLength Minimum required length (default: 0)
|
|
36
|
+
* @returns The validated array
|
|
37
|
+
* @throws ArgumentError if value is not an array or doesn't meet minimum length
|
|
38
|
+
*/
|
|
39
|
+
static validateArray<T>(value: any, fieldName: string, minLength = 0): T[] {
|
|
40
|
+
if (!Array.isArray(value)) {
|
|
41
|
+
throw new ArgumentError(`${fieldName} must be an array`);
|
|
42
|
+
}
|
|
43
|
+
if (value.length < minLength) {
|
|
44
|
+
throw new ArgumentError(`${fieldName} must have at least ${minLength} items`);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validates that a value is one of the allowed enum values
|
|
51
|
+
* @param value The value to validate
|
|
52
|
+
* @param validValues Array of valid values
|
|
53
|
+
* @param fieldName The name of the field for error messages
|
|
54
|
+
* @returns The validated value as the enum type
|
|
55
|
+
* @throws ArgumentError if value is not in validValues
|
|
56
|
+
*/
|
|
57
|
+
static validateEnum<T extends string>(value: string, validValues: readonly T[], fieldName: string): T {
|
|
58
|
+
if (!validValues.includes(value as T)) {
|
|
59
|
+
throw new ArgumentError(`${fieldName} must be one of [${validValues.join(', ')}], got: ${value}`);
|
|
60
|
+
}
|
|
61
|
+
return value as T;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Validates that all items in an array are strings
|
|
66
|
+
* @param value Array to validate
|
|
67
|
+
* @param fieldName The name of the field for error messages
|
|
68
|
+
* @throws ArgumentError if any item is not a string
|
|
69
|
+
*/
|
|
70
|
+
static validateStringArray(value: any[], fieldName: string): void {
|
|
71
|
+
for (let i = 0; i < value.length; i++) {
|
|
72
|
+
if (typeof value[i] !== 'string') {
|
|
73
|
+
throw new ArgumentError(`All ${fieldName} must be strings, but item at index ${i} is not`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
-
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
|
|
4
|
-
import { Resource } from './types/general';
|
|
5
|
-
export declare class AuthorizationAttributesService {
|
|
6
|
-
private static LOG_TAG;
|
|
7
|
-
private static API_PATHS;
|
|
8
|
-
private httpClient;
|
|
9
|
-
private fetchOptions;
|
|
10
|
-
private snsArn;
|
|
11
|
-
/**
|
|
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.
|
|
15
|
-
*/
|
|
16
|
-
constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
|
|
17
|
-
/**
|
|
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.
|
|
23
|
-
*/
|
|
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: ResourceAttributesOperation[]): Promise<ResourceAttributesOperation[]>;
|
|
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>;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=authorization-attributes-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,2BAA2B,EAC5B,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,2BAA2B,EAAE,GACzD,OAAO,CAAC,2BAA2B,EAAE,CAAC;YAY3B,oBAAoB;IA4BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAW7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const chunk = require('lodash/chunk.js');
|
|
4
|
-
const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
|
|
5
|
-
const mondaySns = require('@mondaydotcomorg/monday-sns');
|
|
6
|
-
const mondayFetchApi = require('@mondaydotcomorg/monday-fetch-api');
|
|
7
|
-
const authorizationInternalService = require('./authorization-internal-service.js');
|
|
8
|
-
const attributionsService = require('./attributions-service.js');
|
|
9
|
-
const constants_sns = require('./constants/sns.js');
|
|
10
|
-
const constants = require('./constants.js');
|
|
11
|
-
|
|
12
|
-
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
13
|
-
|
|
14
|
-
const chunk__default = /*#__PURE__*/_interopDefault(chunk);
|
|
15
|
-
|
|
16
|
-
class AuthorizationAttributesService {
|
|
17
|
-
static LOG_TAG = 'authorization_attributes';
|
|
18
|
-
static API_PATHS = {
|
|
19
|
-
UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
|
|
20
|
-
DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
|
|
21
|
-
};
|
|
22
|
-
httpClient;
|
|
23
|
-
fetchOptions;
|
|
24
|
-
snsArn;
|
|
25
|
-
/**
|
|
26
|
-
* Public constructor to create the AuthorizationAttributesService instance.
|
|
27
|
-
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
28
|
-
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
29
|
-
*/
|
|
30
|
-
constructor(httpClient, fetchOptions) {
|
|
31
|
-
if (!httpClient) {
|
|
32
|
-
httpClient = tridentBackendApi.Api.getPart('httpClient');
|
|
33
|
-
if (!httpClient) {
|
|
34
|
-
throw new Error(constants.ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!fetchOptions) {
|
|
38
|
-
fetchOptions = constants.DEFAULT_FETCH_OPTIONS;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
fetchOptions = {
|
|
42
|
-
...constants.DEFAULT_FETCH_OPTIONS,
|
|
43
|
-
...fetchOptions,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
this.httpClient = httpClient;
|
|
47
|
-
this.fetchOptions = fetchOptions;
|
|
48
|
-
this.snsArn = AuthorizationAttributesService.getSnsTopicArn();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
52
|
-
* @param accountId
|
|
53
|
-
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
54
|
-
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
55
|
-
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
56
|
-
*/
|
|
57
|
-
async upsertResourceAttributes(accountId, resourceAttributeAssignments) {
|
|
58
|
-
const attributionHeaders = attributionsService.getAttributionsFromApi();
|
|
59
|
-
try {
|
|
60
|
-
return await this.httpClient.fetch({
|
|
61
|
-
url: {
|
|
62
|
-
appName: constants.APP_NAME,
|
|
63
|
-
path: AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString()),
|
|
64
|
-
},
|
|
65
|
-
method: 'POST',
|
|
66
|
-
headers: {
|
|
67
|
-
'Content-Type': 'application/json',
|
|
68
|
-
...attributionHeaders,
|
|
69
|
-
},
|
|
70
|
-
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
71
|
-
}, this.fetchOptions);
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
if (err instanceof mondayFetchApi.HttpFetcherError) {
|
|
75
|
-
throw new Error(constants.ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributes', err.status, err.message));
|
|
76
|
-
}
|
|
77
|
-
throw err;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
82
|
-
* @param accountId
|
|
83
|
-
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
84
|
-
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
85
|
-
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
86
|
-
*/
|
|
87
|
-
async deleteResourceAttributes(accountId, resource, attributeKeys) {
|
|
88
|
-
const attributionHeaders = attributionsService.getAttributionsFromApi();
|
|
89
|
-
if (!resource.id) {
|
|
90
|
-
throw new Error('Resource ID is required');
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
return await this.httpClient.fetch({
|
|
94
|
-
url: {
|
|
95
|
-
appName: constants.APP_NAME,
|
|
96
|
-
path: AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
|
|
97
|
-
.replace('{resourceType}', resource.type)
|
|
98
|
-
.replace('{resourceId}', resource.id.toString()),
|
|
99
|
-
},
|
|
100
|
-
method: 'DELETE',
|
|
101
|
-
headers: {
|
|
102
|
-
'Content-Type': 'application/json',
|
|
103
|
-
...attributionHeaders,
|
|
104
|
-
},
|
|
105
|
-
body: JSON.stringify({ keys: attributeKeys }),
|
|
106
|
-
}, this.fetchOptions);
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
if (err instanceof mondayFetchApi.HttpFetcherError) {
|
|
110
|
-
throw new Error(constants.ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributes', err.status, err.message));
|
|
111
|
-
}
|
|
112
|
-
throw err;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
117
|
-
* @param accountId
|
|
118
|
-
* @param appName - App name of the calling app
|
|
119
|
-
* @param callerActionIdentifier - action identifier
|
|
120
|
-
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
121
|
-
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
122
|
-
* */
|
|
123
|
-
async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
|
|
124
|
-
const topicArn = this.snsArn;
|
|
125
|
-
const sendToSnsPromises = [];
|
|
126
|
-
const operationChucks = chunk__default.default(resourceAttributeOperations, constants_sns.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
|
|
127
|
-
for (const operationsChunk of operationChucks) {
|
|
128
|
-
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
|
|
129
|
-
}
|
|
130
|
-
return (await Promise.all(sendToSnsPromises)).flat();
|
|
131
|
-
}
|
|
132
|
-
async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
|
|
133
|
-
const payload = {
|
|
134
|
-
kind: constants_sns.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
|
|
135
|
-
payload: {
|
|
136
|
-
accountId: accountId,
|
|
137
|
-
callerAppName: appName,
|
|
138
|
-
callerActionIdentifier: callerActionIdentifier,
|
|
139
|
-
operations: operations,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
try {
|
|
143
|
-
await mondaySns.sendToSns(payload, topicArn);
|
|
144
|
-
return operations;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'Authorization resource attributes async update: failed to send operations to SNS');
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
static getSnsTopicArn() {
|
|
152
|
-
const arnFromEnv = process.env[constants_sns.SNS_ARN_ENV_VAR_NAME];
|
|
153
|
-
if (arnFromEnv) {
|
|
154
|
-
return arnFromEnv;
|
|
155
|
-
}
|
|
156
|
-
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
157
|
-
return constants_sns.SNS_DEV_TEST_NAME;
|
|
158
|
-
}
|
|
159
|
-
throw new Error('Unable to get sns topic arn from env variable');
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
163
|
-
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
164
|
-
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
165
|
-
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
166
|
-
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
167
|
-
* @return {Promise<boolean>} - true if succeeded
|
|
168
|
-
*/
|
|
169
|
-
async asyncResourceAttributesHealthCheck() {
|
|
170
|
-
try {
|
|
171
|
-
const requestedTopicArn = this.snsArn;
|
|
172
|
-
const attributes = await mondaySns.getTopicAttributes(requestedTopicArn);
|
|
173
|
-
const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
|
|
174
|
-
if (!isHealthy) {
|
|
175
|
-
authorizationInternalService.logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service failed in health check');
|
|
176
|
-
}
|
|
177
|
-
return isHealthy;
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service got error during health check');
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
exports.AuthorizationAttributesService = AuthorizationAttributesService;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
-
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
|
|
4
|
-
import { Resource } from './types/general';
|
|
5
|
-
export declare class AuthorizationAttributesService {
|
|
6
|
-
private static LOG_TAG;
|
|
7
|
-
private static API_PATHS;
|
|
8
|
-
private httpClient;
|
|
9
|
-
private fetchOptions;
|
|
10
|
-
private snsArn;
|
|
11
|
-
/**
|
|
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.
|
|
15
|
-
*/
|
|
16
|
-
constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
|
|
17
|
-
/**
|
|
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.
|
|
23
|
-
*/
|
|
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: ResourceAttributesOperation[]): Promise<ResourceAttributesOperation[]>;
|
|
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>;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=authorization-attributes-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,2BAA2B,EAC5B,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,2BAA2B,EAAE,GACzD,OAAO,CAAC,2BAA2B,EAAE,CAAC;YAY3B,oBAAoB;IA4BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAW7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -1,180 +0,0 @@
|
|
|
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';
|
|
9
|
-
|
|
10
|
-
class AuthorizationAttributesService {
|
|
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;
|
|
19
|
-
/**
|
|
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.
|
|
23
|
-
*/
|
|
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;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
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.
|
|
80
|
-
*/
|
|
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;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export { AuthorizationAttributesService };
|