@mondaydotcomorg/monday-authorization 3.5.1-feat-shaime-support-entity-attributes-in-authorization-sdk-d2be13e → 3.5.1-fix-authorize-profile-picker-9fcaf6a

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.
Files changed (114) hide show
  1. package/dist/attributions-service.d.ts.map +1 -1
  2. package/dist/attributions-service.js +0 -1
  3. package/dist/authorization-attributes-service.d.ts +54 -0
  4. package/dist/authorization-attributes-service.d.ts.map +1 -0
  5. package/dist/authorization-attributes-service.js +186 -0
  6. package/dist/authorization-service.d.ts.map +1 -1
  7. package/dist/authorization-service.js +34 -7
  8. package/dist/constants/sns.d.ts +2 -12
  9. package/dist/constants/sns.d.ts.map +1 -1
  10. package/dist/constants/sns.js +2 -22
  11. package/dist/esm/attributions-service.d.ts.map +1 -1
  12. package/dist/esm/attributions-service.mjs +0 -1
  13. package/dist/esm/authorization-attributes-service.d.ts +54 -0
  14. package/dist/esm/authorization-attributes-service.d.ts.map +1 -0
  15. package/dist/esm/authorization-attributes-service.mjs +180 -0
  16. package/dist/esm/authorization-service.d.ts.map +1 -1
  17. package/dist/esm/authorization-service.mjs +34 -7
  18. package/dist/esm/constants/sns.d.ts +2 -12
  19. package/dist/esm/constants/sns.d.ts.map +1 -1
  20. package/dist/esm/constants/sns.mjs +3 -17
  21. package/dist/esm/index.d.ts +1 -9
  22. package/dist/esm/index.d.ts.map +1 -1
  23. package/dist/esm/index.mjs +1 -7
  24. package/dist/esm/roles-service.d.ts +1 -1
  25. package/dist/esm/roles-service.mjs +1 -1
  26. package/dist/esm/types/authorization-attributes-contracts.d.ts +4 -36
  27. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  28. package/dist/esm/types/authorization-attributes-contracts.mjs +1 -6
  29. package/dist/index.d.ts +1 -9
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -15
  32. package/dist/roles-service.d.ts +1 -1
  33. package/dist/roles-service.js +1 -1
  34. package/dist/types/authorization-attributes-contracts.d.ts +4 -36
  35. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  36. package/dist/types/authorization-attributes-contracts.js +0 -5
  37. package/package.json +1 -1
  38. package/src/attributions-service.ts +0 -4
  39. package/src/authorization-attributes-service.ts +234 -0
  40. package/src/authorization-service.ts +71 -11
  41. package/src/constants/sns.ts +2 -19
  42. package/src/index.ts +1 -18
  43. package/src/roles-service.ts +1 -1
  44. package/src/types/authorization-attributes-contracts.ts +3 -56
  45. package/dist/authorization-attributes-ms-service.d.ts +0 -67
  46. package/dist/authorization-attributes-ms-service.d.ts.map +0 -1
  47. package/dist/authorization-attributes-ms-service.js +0 -256
  48. package/dist/authorization-attributes-sns-service.d.ts +0 -85
  49. package/dist/authorization-attributes-sns-service.d.ts.map +0 -1
  50. package/dist/authorization-attributes-sns-service.js +0 -203
  51. package/dist/base-attribute-assignment.d.ts +0 -18
  52. package/dist/base-attribute-assignment.d.ts.map +0 -1
  53. package/dist/base-attribute-assignment.js +0 -43
  54. package/dist/entity-attribute-assignment.d.ts +0 -24
  55. package/dist/entity-attribute-assignment.d.ts.map +0 -1
  56. package/dist/entity-attribute-assignment.js +0 -36
  57. package/dist/entity-attributes-constants.d.ts +0 -7
  58. package/dist/entity-attributes-constants.d.ts.map +0 -1
  59. package/dist/entity-attributes-constants.js +0 -9
  60. package/dist/errors/argument-error.d.ts +0 -4
  61. package/dist/errors/argument-error.d.ts.map +0 -1
  62. package/dist/errors/argument-error.js +0 -11
  63. package/dist/esm/authorization-attributes-ms-service.d.ts +0 -67
  64. package/dist/esm/authorization-attributes-ms-service.d.ts.map +0 -1
  65. package/dist/esm/authorization-attributes-ms-service.mjs +0 -254
  66. package/dist/esm/authorization-attributes-sns-service.d.ts +0 -85
  67. package/dist/esm/authorization-attributes-sns-service.d.ts.map +0 -1
  68. package/dist/esm/authorization-attributes-sns-service.mjs +0 -197
  69. package/dist/esm/base-attribute-assignment.d.ts +0 -18
  70. package/dist/esm/base-attribute-assignment.d.ts.map +0 -1
  71. package/dist/esm/base-attribute-assignment.mjs +0 -41
  72. package/dist/esm/entity-attribute-assignment.d.ts +0 -24
  73. package/dist/esm/entity-attribute-assignment.d.ts.map +0 -1
  74. package/dist/esm/entity-attribute-assignment.mjs +0 -34
  75. package/dist/esm/entity-attributes-constants.d.ts +0 -7
  76. package/dist/esm/entity-attributes-constants.d.ts.map +0 -1
  77. package/dist/esm/entity-attributes-constants.mjs +0 -7
  78. package/dist/esm/errors/argument-error.d.ts +0 -4
  79. package/dist/esm/errors/argument-error.d.ts.map +0 -1
  80. package/dist/esm/errors/argument-error.mjs +0 -9
  81. package/dist/esm/resource-attribute-assignment.d.ts +0 -24
  82. package/dist/esm/resource-attribute-assignment.d.ts.map +0 -1
  83. package/dist/esm/resource-attribute-assignment.mjs +0 -34
  84. package/dist/esm/resource-attributes-constants.d.ts +0 -25
  85. package/dist/esm/resource-attributes-constants.d.ts.map +0 -1
  86. package/dist/esm/resource-attributes-constants.mjs +0 -25
  87. package/dist/esm/utils/path-utils.d.ts +0 -8
  88. package/dist/esm/utils/path-utils.d.ts.map +0 -1
  89. package/dist/esm/utils/path-utils.mjs +0 -15
  90. package/dist/esm/utils/validation.d.ts +0 -45
  91. package/dist/esm/utils/validation.d.ts.map +0 -1
  92. package/dist/esm/utils/validation.mjs +0 -75
  93. package/dist/resource-attribute-assignment.d.ts +0 -24
  94. package/dist/resource-attribute-assignment.d.ts.map +0 -1
  95. package/dist/resource-attribute-assignment.js +0 -36
  96. package/dist/resource-attributes-constants.d.ts +0 -25
  97. package/dist/resource-attributes-constants.d.ts.map +0 -1
  98. package/dist/resource-attributes-constants.js +0 -28
  99. package/dist/utils/path-utils.d.ts +0 -8
  100. package/dist/utils/path-utils.d.ts.map +0 -1
  101. package/dist/utils/path-utils.js +0 -17
  102. package/dist/utils/validation.d.ts +0 -45
  103. package/dist/utils/validation.d.ts.map +0 -1
  104. package/dist/utils/validation.js +0 -77
  105. package/src/authorization-attributes-ms-service.ts +0 -400
  106. package/src/authorization-attributes-sns-service.ts +0 -290
  107. package/src/base-attribute-assignment.ts +0 -55
  108. package/src/entity-attribute-assignment.ts +0 -35
  109. package/src/entity-attributes-constants.ts +0 -7
  110. package/src/errors/argument-error.ts +0 -7
  111. package/src/resource-attribute-assignment.ts +0 -43
  112. package/src/resource-attributes-constants.ts +0 -26
  113. package/src/utils/path-utils.ts +0 -13
  114. package/src/utils/validation.ts +0 -77
@@ -1 +1 @@
1
- {"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAyClE"}
1
+ {"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAqClE"}
@@ -46,7 +46,6 @@ function getAttributionsFromApi() {
46
46
  const { runtimeAttributions } = tridentContext;
47
47
  const runtimeAttributionsOutgoingHeaders = runtimeAttributions?.buildOutgoingHeaders('HTTP_INTERNAL');
48
48
  if (!runtimeAttributionsOutgoingHeaders) {
49
- authorizationInternalService.logger.info({ tag: 'authorization-service', runtimeAttributionsOutgoingHeaders }, 'No runtime attributions outgoing headers');
50
49
  return callerAppNameFromSdk;
51
50
  }
52
51
  const attributionsHeaders = Object.fromEntries(runtimeAttributionsOutgoingHeaders);
@@ -0,0 +1,54 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,186 @@
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 +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,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,mBAA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ationService: igniteClient is not set, failing request');
97
97
  throw new Error('AuthorizationService: igniteClient is not set, failing request');
98
98
  }
99
- if (this.igniteClient.configuration.getObjectValue(ALLOWED_SDK_PLATFORM_PROFILES_KEY, []).includes(appName)) {
100
- return attributionsService.getProfile();
99
+ const allowedProfiles = this.igniteClient.configuration.getObjectValue(ALLOWED_SDK_PLATFORM_PROFILES_KEY, []);
100
+ const isAllowedProfile = allowedProfiles.includes(appName);
101
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, appName, allowedProfiles, isAllowedProfile }, 'AuthorizationService.getProfile: checking allowed profiles');
102
+ if (isAllowedProfile) {
103
+ const profile = attributionsService.getProfile();
104
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via allowed profiles');
105
+ return profile;
101
106
  }
102
- if (this.igniteClient.configuration
103
- .getObjectValue(IN_RELEASE_SDK_PLATFORM_PROFILES_KEY, [])
104
- .includes(appName) &&
105
- this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId })) {
106
- return attributionsService.getProfile();
107
+ const inReleaseProfiles = this.igniteClient.configuration.getObjectValue(IN_RELEASE_SDK_PLATFORM_PROFILES_KEY, []);
108
+ const isInReleaseProfile = inReleaseProfiles.includes(appName);
109
+ const isFeatureFlagReleased = this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId });
110
+ authorizationInternalService.logger.info({
111
+ tag: 'auth-debug',
112
+ accountId,
113
+ userId,
114
+ appName,
115
+ inReleaseProfiles,
116
+ isInReleaseProfile,
117
+ isFeatureFlagReleased,
118
+ featureFlag: PLATFORM_PROFILE_RELEASE_FF,
119
+ }, 'AuthorizationService.getProfile: checking feature flag release');
120
+ if (isInReleaseProfile && isFeatureFlagReleased) {
121
+ const profile = attributionsService.getProfile();
122
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via feature flag release');
123
+ return profile;
107
124
  }
125
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, appName, profile: attributionsService.PlatformProfile.APP }, 'AuthorizationService.getProfile: selected default APP profile');
108
126
  return attributionsService.PlatformProfile.APP;
109
127
  }
110
128
  static async canActionInScopeMultiple(accountId, userId, scopedActions) {
@@ -112,15 +130,24 @@ class AuthorizationService {
112
130
  return [];
113
131
  }
114
132
  const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
133
+ authorizationInternalService.logger.info({
134
+ tag: 'auth-debug',
135
+ accountId,
136
+ userId,
137
+ shouldNavigateToGraph,
138
+ featureFlag: NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF,
139
+ }, 'AuthorizationService.canActionInScopeMultiple: determining which API flow to use');
115
140
  const startTime = perf_hooks.performance.now();
116
141
  let scopedActionResponseObjects;
117
142
  let apiType;
118
143
  if (shouldNavigateToGraph) {
119
144
  apiType = 'graph';
145
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using graph API flow');
120
146
  scopedActionResponseObjects = await this.graphApi.checkPermissions(accountId, userId, scopedActions);
121
147
  }
122
148
  else {
123
149
  apiType = 'platform';
150
+ authorizationInternalService.logger.info({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using platform API flow');
124
151
  const profile = this.getProfile(accountId, userId);
125
152
  const internalAuthToken = authorizationInternalService.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
126
153
  scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
@@ -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,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
+ {"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,31 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- exports.SnsTopicType = void 0;
4
- (function (SnsTopicType) {
5
- SnsTopicType["RESOURCE"] = "resource";
6
- SnsTopicType["ENTITY"] = "entity";
7
- })(exports.SnsTopicType || (exports.SnsTopicType = {}));
8
- // Resource SNS constants
9
- const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
10
- const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
11
- // Entity SNS constants
12
- const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
13
- const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
3
+ const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
4
+ const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
14
5
  const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
15
- const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
16
6
  const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
17
- const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
18
- // Legacy exports for backward compatibility
19
- const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
20
- const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
21
7
 
22
- exports.ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE;
23
8
  exports.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE;
24
- exports.ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND;
25
- exports.ENTITY_SNS_ARN_ENV_VAR_NAME = ENTITY_SNS_ARN_ENV_VAR_NAME;
26
- exports.ENTITY_SNS_DEV_TEST_NAME = ENTITY_SNS_DEV_TEST_NAME;
27
9
  exports.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND;
28
- exports.RESOURCE_SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
29
- exports.RESOURCE_SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
30
10
  exports.SNS_ARN_ENV_VAR_NAME = SNS_ARN_ENV_VAR_NAME;
31
11
  exports.SNS_DEV_TEST_NAME = SNS_DEV_TEST_NAME;
@@ -1 +1 @@
1
- {"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAyClE"}
1
+ {"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAqClE"}
@@ -44,7 +44,6 @@ function getAttributionsFromApi() {
44
44
  const { runtimeAttributions } = tridentContext;
45
45
  const runtimeAttributionsOutgoingHeaders = runtimeAttributions?.buildOutgoingHeaders('HTTP_INTERNAL');
46
46
  if (!runtimeAttributionsOutgoingHeaders) {
47
- logger.info({ tag: 'authorization-service', runtimeAttributionsOutgoingHeaders }, 'No runtime attributions outgoing headers');
48
47
  return callerAppNameFromSdk;
49
48
  }
50
49
  const attributionsHeaders = Object.fromEntries(runtimeAttributionsOutgoingHeaders);
@@ -0,0 +1,54 @@
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
@@ -0,0 +1 @@
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"}