@mondaydotcomorg/monday-authorization 3.3.0-feature-bashanye-navigate-can-action-in-scope-to-graph-2d70b30 → 3.3.1-feature-bashanye-add-membership-create-delete-api-d00c165
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/README.md +143 -11
- package/dist/attributions-service.d.ts +3 -2
- package/dist/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +1 -0
- package/dist/authorization-internal-service.d.ts +1 -1
- package/dist/authorization-internal-service.d.ts.map +1 -1
- package/dist/authorization-service.d.ts +5 -0
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +30 -26
- package/dist/clients/graph-api.d.ts +28 -0
- package/dist/clients/graph-api.d.ts.map +1 -0
- package/dist/clients/{graph-api.client.js → graph-api.js} +48 -40
- package/dist/clients/platform-api.d.ts +26 -0
- package/dist/clients/platform-api.d.ts.map +1 -0
- package/dist/clients/{platform-api.client.js → platform-api.js} +20 -20
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/esm/attributions-service.d.ts +3 -2
- package/dist/esm/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +1 -0
- package/dist/esm/authorization-internal-service.d.ts +1 -1
- package/dist/esm/authorization-internal-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.d.ts +5 -0
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +31 -27
- package/dist/esm/clients/graph-api.d.ts +28 -0
- package/dist/esm/clients/graph-api.d.ts.map +1 -0
- package/dist/esm/clients/{graph-api.client.mjs → graph-api.mjs} +48 -40
- package/dist/esm/clients/platform-api.d.ts +26 -0
- package/dist/esm/clients/platform-api.d.ts.map +1 -0
- package/dist/esm/clients/{platform-api.client.mjs → platform-api.mjs} +21 -21
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +2 -1
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/memberships.d.ts +30 -0
- package/dist/esm/memberships.d.ts.map +1 -0
- package/dist/esm/memberships.mjs +98 -0
- package/dist/esm/metrics-service.d.ts +12 -0
- package/dist/esm/metrics-service.d.ts.map +1 -0
- package/dist/esm/metrics-service.mjs +54 -0
- package/dist/esm/prometheus-service.d.ts +1 -3
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/prometheus-service.mjs +5 -58
- package/dist/esm/types/graph-api.types.d.ts +8 -7
- package/dist/esm/types/graph-api.types.d.ts.map +1 -1
- package/dist/esm/types/memberships.d.ts +42 -0
- package/dist/esm/types/memberships.d.ts.map +1 -0
- package/dist/esm/types/memberships.mjs +1 -0
- package/dist/esm/types/scoped-actions-contracts.d.ts +10 -1
- package/dist/esm/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/esm/types/scoped-actions-contracts.mjs +9 -0
- package/dist/esm/utils/api-error-handler.d.ts +2 -0
- package/dist/esm/utils/api-error-handler.d.ts.map +1 -0
- package/dist/esm/utils/api-error-handler.mjs +18 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/memberships.d.ts +30 -0
- package/dist/memberships.d.ts.map +1 -0
- package/dist/memberships.js +100 -0
- package/dist/metrics-service.d.ts +12 -0
- package/dist/metrics-service.d.ts.map +1 -0
- package/dist/metrics-service.js +58 -0
- package/dist/prometheus-service.d.ts +1 -3
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/prometheus-service.js +4 -59
- package/dist/types/graph-api.types.d.ts +8 -7
- package/dist/types/graph-api.types.d.ts.map +1 -1
- package/dist/types/memberships.d.ts +42 -0
- package/dist/types/memberships.d.ts.map +1 -0
- package/dist/types/memberships.js +1 -0
- package/dist/types/scoped-actions-contracts.d.ts +10 -1
- package/dist/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/types/scoped-actions-contracts.js +9 -0
- package/dist/utils/api-error-handler.d.ts +2 -0
- package/dist/utils/api-error-handler.d.ts.map +1 -0
- package/dist/utils/api-error-handler.js +20 -0
- package/package.json +5 -2
- package/src/attributions-service.ts +93 -0
- package/src/authorization-attributes-service.ts +234 -0
- package/src/authorization-internal-service.ts +129 -0
- package/src/authorization-middleware.ts +51 -0
- package/src/authorization-service.ts +356 -0
- package/src/clients/graph-api.ts +170 -0
- package/src/clients/platform-api.ts +117 -0
- package/src/constants/sns.ts +5 -0
- package/src/constants.ts +23 -0
- package/src/index.ts +63 -0
- package/src/memberships.ts +111 -0
- package/src/metrics-service.ts +71 -0
- package/src/prometheus-service.ts +51 -0
- package/src/roles-service.ts +125 -0
- package/src/testKit/index.ts +69 -0
- package/src/types/authorization-attributes-contracts.ts +33 -0
- package/src/types/express.ts +8 -0
- package/src/types/general.ts +32 -0
- package/src/types/graph-api.types.ts +25 -0
- package/src/types/memberships.ts +47 -0
- package/src/types/roles.ts +42 -0
- package/src/types/scoped-actions-contracts.ts +57 -0
- package/src/utils/api-error-handler.ts +25 -0
- package/src/utils/authorization.utils.ts +47 -0
- package/dist/clients/graph-api.client.d.ts +0 -24
- package/dist/clients/graph-api.client.d.ts.map +0 -1
- package/dist/clients/platform-api.client.d.ts +0 -31
- package/dist/clients/platform-api.client.d.ts.map +0 -1
- package/dist/esm/clients/graph-api.client.d.ts +0 -24
- package/dist/esm/clients/graph-api.client.d.ts.map +0 -1
- package/dist/esm/clients/platform-api.client.d.ts +0 -31
- package/dist/esm/clients/platform-api.client.d.ts.map +0 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
2
|
import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
export declare const APP_NAME = "authorization";
|
|
4
|
+
export declare const GRAPH_APP_NAME = "authorization-graph";
|
|
4
5
|
export declare const ERROR_MESSAGES: {
|
|
5
6
|
readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
|
|
6
7
|
readonly REQUEST_FAILED: (method: string, status: number, reason: string) => string;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAUjE,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const APP_NAME = 'authorization';
|
|
4
|
+
const GRAPH_APP_NAME = 'authorization-graph';
|
|
4
5
|
const ERROR_MESSAGES = {
|
|
5
6
|
HTTP_CLIENT_NOT_INITIALIZED: 'MondayAuthorization: HTTP client is not initialized',
|
|
6
7
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
@@ -20,3 +21,4 @@ const DEFAULT_FETCH_OPTIONS = {
|
|
|
20
21
|
exports.APP_NAME = APP_NAME;
|
|
21
22
|
exports.DEFAULT_FETCH_OPTIONS = DEFAULT_FETCH_OPTIONS;
|
|
22
23
|
exports.ERROR_MESSAGES = ERROR_MESSAGES;
|
|
24
|
+
exports.GRAPH_APP_NAME = GRAPH_APP_NAME;
|
|
@@ -2,9 +2,10 @@ import { Context, ExecutionContext } from '@mondaydotcomorg/trident-backend-api'
|
|
|
2
2
|
export declare enum PlatformProfile {
|
|
3
3
|
API_INTERNAL = "api-internal",
|
|
4
4
|
SLOW = "slow",
|
|
5
|
-
INTERNAL = "internal"
|
|
5
|
+
INTERNAL = "internal",
|
|
6
|
+
APP = "app"
|
|
6
7
|
}
|
|
7
|
-
export declare function getProfile(): PlatformProfile;
|
|
8
|
+
export declare function getProfile(): PlatformProfile.API_INTERNAL | PlatformProfile.SLOW | PlatformProfile.INTERNAL;
|
|
8
9
|
export declare function getExecutionContext(context: Context): ExecutionContext;
|
|
9
10
|
export declare function getAttributionsFromApi(): {
|
|
10
11
|
[key: string]: string;
|
|
@@ -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;
|
|
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"}
|
|
@@ -10,6 +10,7 @@ var PlatformProfile;
|
|
|
10
10
|
PlatformProfile["API_INTERNAL"] = "api-internal";
|
|
11
11
|
PlatformProfile["SLOW"] = "slow";
|
|
12
12
|
PlatformProfile["INTERNAL"] = "internal";
|
|
13
|
+
PlatformProfile["APP"] = "app";
|
|
13
14
|
})(PlatformProfile || (PlatformProfile = {}));
|
|
14
15
|
function getProfile() {
|
|
15
16
|
const tridentContext = Api.getPart('context');
|
|
@@ -10,7 +10,7 @@ export declare class AuthorizationInternalService {
|
|
|
10
10
|
static markAuthorized(request: BaseRequest): void;
|
|
11
11
|
static failIfNotCoveredByAuthorization(request: BaseRequest): void;
|
|
12
12
|
static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
|
|
13
|
-
static throwOnHttpError(status: number, placement: string):
|
|
13
|
+
static throwOnHttpError(status: number, placement: string): never;
|
|
14
14
|
static generateInternalAuthToken(accountId: number, userId: number): string;
|
|
15
15
|
static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
|
|
16
16
|
static getRequestFetchOptions(): MondayFetchOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../../src/authorization-internal-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAyB,eAAe,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAO/C,eAAO,MAAM,eAAe,EAAE,eAM7B,CAAC;A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S,EAAE,MAAM,GAAG,IAAI;IAcrG,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IAQjE,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAIlE,MAAM,CAAC,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB;IAO1E,MAAM,CAAC,sBAAsB,IAAI,kBAAkB;IAInD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY;IAI3C,MAAM,CAAC,iBAAiB;IA2BxB,MAAM,CAAC,gBAAgB,IAAI,WAAW;CASvC"}
|
|
@@ -9,6 +9,11 @@ export interface AuthorizeResponse {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
|
|
11
11
|
export declare class AuthorizationService {
|
|
12
|
+
private static get graphApi();
|
|
13
|
+
private static _graphApi?;
|
|
14
|
+
private static get platformApi();
|
|
15
|
+
private static _platformApi?;
|
|
16
|
+
static resetApiClients(): void;
|
|
12
17
|
static redisClient?: any;
|
|
13
18
|
static grantedFeatureRedisExpirationInSeconds?: number;
|
|
14
19
|
static igniteClient?: IgniteClient;
|
|
@@ -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;
|
|
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,EAA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AC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;IAM9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAsBZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
|
|
@@ -2,11 +2,12 @@ import { performance } from 'perf_hooks';
|
|
|
2
2
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
4
4
|
import { getIgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
5
|
-
import { sendAuthorizationCheckResponseTimeMetric
|
|
5
|
+
import { sendAuthorizationCheckResponseTimeMetric } from './prometheus-service.mjs';
|
|
6
|
+
import { recordAuthorizationTiming } from './metrics-service.mjs';
|
|
6
7
|
import { AuthorizationInternalService, logger } from './authorization-internal-service.mjs';
|
|
7
8
|
import { getProfile, PlatformProfile, getAttributionsFromApi } from './attributions-service.mjs';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { GraphApi } from './clients/graph-api.mjs';
|
|
10
|
+
import { PlatformApi } from './clients/platform-api.mjs';
|
|
10
11
|
import { scopeToResource } from './utils/authorization.utils.mjs';
|
|
11
12
|
|
|
12
13
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
@@ -19,6 +20,24 @@ function setRequestFetchOptions(customMondayFetchOptions) {
|
|
|
19
20
|
AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
20
21
|
}
|
|
21
22
|
class AuthorizationService {
|
|
23
|
+
static get graphApi() {
|
|
24
|
+
if (!this._graphApi) {
|
|
25
|
+
this._graphApi = new GraphApi();
|
|
26
|
+
}
|
|
27
|
+
return this._graphApi;
|
|
28
|
+
}
|
|
29
|
+
static _graphApi;
|
|
30
|
+
static get platformApi() {
|
|
31
|
+
if (!this._platformApi) {
|
|
32
|
+
this._platformApi = new PlatformApi();
|
|
33
|
+
}
|
|
34
|
+
return this._platformApi;
|
|
35
|
+
}
|
|
36
|
+
static _platformApi;
|
|
37
|
+
static resetApiClients() {
|
|
38
|
+
this._graphApi = undefined;
|
|
39
|
+
this._platformApi = undefined;
|
|
40
|
+
}
|
|
22
41
|
static redisClient;
|
|
23
42
|
static grantedFeatureRedisExpirationInSeconds;
|
|
24
43
|
static igniteClient;
|
|
@@ -84,38 +103,25 @@ class AuthorizationService {
|
|
|
84
103
|
this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId })) {
|
|
85
104
|
return getProfile();
|
|
86
105
|
}
|
|
87
|
-
return PlatformProfile.
|
|
106
|
+
return PlatformProfile.APP;
|
|
88
107
|
}
|
|
89
108
|
static async canActionInScopeMultiple(accountId, userId, scopedActions) {
|
|
90
109
|
if (scopedActions.length === 0) {
|
|
91
110
|
return [];
|
|
92
111
|
}
|
|
93
112
|
const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
|
|
94
|
-
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
95
113
|
const startTime = performance.now();
|
|
96
114
|
let scopedActionResponseObjects;
|
|
97
115
|
let apiType;
|
|
98
116
|
if (shouldNavigateToGraph) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
apiType = 'graph';
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
const status = error instanceof HttpFetcherError ? error.status : undefined;
|
|
105
|
-
logger.warn({
|
|
106
|
-
tag: 'authorization-service',
|
|
107
|
-
error: error instanceof Error ? error.message : String(error),
|
|
108
|
-
accountId,
|
|
109
|
-
userId,
|
|
110
|
-
status,
|
|
111
|
-
}, 'Graph API authorization failed');
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
117
|
+
apiType = 'graph';
|
|
118
|
+
scopedActionResponseObjects = await this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
114
119
|
}
|
|
115
120
|
else {
|
|
116
|
-
const profile = this.getProfile(accountId, userId);
|
|
117
|
-
scopedActionResponseObjects = await PlatformApiClient.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
118
121
|
apiType = 'platform';
|
|
122
|
+
const profile = this.getProfile(accountId, userId);
|
|
123
|
+
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
124
|
+
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
119
125
|
}
|
|
120
126
|
const endTime = performance.now();
|
|
121
127
|
const time = endTime - startTime;
|
|
@@ -124,10 +130,8 @@ class AuthorizationService {
|
|
|
124
130
|
const { action, scope } = obj.scopedAction;
|
|
125
131
|
const { resourceType } = scopeToResource(scope);
|
|
126
132
|
const isAuthorized = obj.permit.can;
|
|
127
|
-
sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, 200, time
|
|
128
|
-
|
|
129
|
-
incrementAuthorizationSuccess(resourceType, action, apiType);
|
|
130
|
-
}
|
|
133
|
+
sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, 200, time);
|
|
134
|
+
recordAuthorizationTiming(apiType, time, 'canActionInScopeMultiple');
|
|
131
135
|
}
|
|
132
136
|
return scopedActionResponseObjects;
|
|
133
137
|
}
|
|
@@ -184,7 +188,7 @@ class AuthorizationService {
|
|
|
184
188
|
if (!isAuthorized) {
|
|
185
189
|
unauthorizedObjects.push(authorizationObject);
|
|
186
190
|
}
|
|
187
|
-
sendAuthorizationCheckResponseTimeMetric(authorizationObject.resource_type, authorizationObject.action, isAuthorized, 200, time
|
|
191
|
+
sendAuthorizationCheckResponseTimeMetric(authorizationObject.resource_type, authorizationObject.action, isAuthorized, 200, time);
|
|
188
192
|
});
|
|
189
193
|
if (unauthorizedObjects.length > 0) {
|
|
190
194
|
logger.info({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ScopedAction, ScopedActionResponseObject } from '../types/scoped-actions-contracts';
|
|
2
|
+
import { GraphIsAllowedResponse } from '../types/graph-api.types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for handling Graph API authorization operations
|
|
5
|
+
*/
|
|
6
|
+
export declare class GraphApi {
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
private readonly consumerAppName;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Builds the request body for Graph API calls
|
|
12
|
+
*/
|
|
13
|
+
private static buildRequestBody;
|
|
14
|
+
/**
|
|
15
|
+
* Fetches authorization data from the Graph API
|
|
16
|
+
*/
|
|
17
|
+
fetchPermissions(authToken: string, scopedActions: ScopedAction[]): Promise<GraphIsAllowedResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Maps Graph API response to the expected format
|
|
20
|
+
*/
|
|
21
|
+
private static mapResponse;
|
|
22
|
+
/**
|
|
23
|
+
* Performs a complete authorization check using the Graph API
|
|
24
|
+
*/
|
|
25
|
+
checkPermissions(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<ScopedActionResponseObject[]>;
|
|
26
|
+
private static ensureGraphReason;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=graph-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AASlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B;;OAEG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAMxC,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAWjC"}
|
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
-
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
2
|
import { PermitTechnicalReason } from '../types/scoped-actions-contracts.mjs';
|
|
4
3
|
import { AuthorizationInternalService } from '../authorization-internal-service.mjs';
|
|
5
4
|
import { getAttributionsFromApi } from '../attributions-service.mjs';
|
|
6
5
|
import { scopeToResource } from '../utils/authorization.utils.mjs';
|
|
7
|
-
import {
|
|
6
|
+
import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
|
|
7
|
+
import { GRAPH_APP_NAME } from '../constants.mjs';
|
|
8
|
+
import { handleApiError } from '../utils/api-error-handler.mjs';
|
|
8
9
|
|
|
9
10
|
const CAN_ACTION_IN_SCOPE_GRAPH_PATH = '/permissions/is-allowed';
|
|
11
|
+
const APP_NAME_REQUIRED_ERROR = 'GraphApi: APP_NAME environment variable is required for Graph API authentication';
|
|
10
12
|
/**
|
|
11
13
|
* Client for handling Graph API authorization operations
|
|
12
14
|
*/
|
|
13
|
-
class
|
|
15
|
+
class GraphApi {
|
|
16
|
+
httpClient;
|
|
17
|
+
consumerAppName;
|
|
18
|
+
constructor() {
|
|
19
|
+
const httpClient = Api.getPart('httpClient');
|
|
20
|
+
if (!httpClient) {
|
|
21
|
+
throw new Error('GraphApi: http client is not initialized');
|
|
22
|
+
}
|
|
23
|
+
const consumerAppName = process.env.APP_NAME?.trim();
|
|
24
|
+
if (!consumerAppName) {
|
|
25
|
+
throw new Error(APP_NAME_REQUIRED_ERROR);
|
|
26
|
+
}
|
|
27
|
+
this.httpClient = httpClient;
|
|
28
|
+
this.consumerAppName = consumerAppName;
|
|
29
|
+
}
|
|
14
30
|
/**
|
|
15
31
|
* Builds the request body for Graph API calls
|
|
16
32
|
*/
|
|
@@ -39,19 +55,18 @@ class GraphApiClient {
|
|
|
39
55
|
/**
|
|
40
56
|
* Fetches authorization data from the Graph API
|
|
41
57
|
*/
|
|
42
|
-
|
|
43
|
-
const httpClient = Api.getPart('httpClient');
|
|
58
|
+
async fetchPermissions(authToken, scopedActions) {
|
|
44
59
|
const attributionHeaders = getAttributionsFromApi();
|
|
45
|
-
const bodyPayload =
|
|
60
|
+
const bodyPayload = GraphApi.buildRequestBody(scopedActions);
|
|
46
61
|
try {
|
|
47
|
-
const response = await httpClient.fetch({
|
|
62
|
+
const response = await this.httpClient.fetch({
|
|
48
63
|
url: {
|
|
49
|
-
appName:
|
|
64
|
+
appName: GRAPH_APP_NAME,
|
|
50
65
|
path: CAN_ACTION_IN_SCOPE_GRAPH_PATH,
|
|
51
66
|
},
|
|
52
67
|
method: 'POST',
|
|
53
68
|
headers: {
|
|
54
|
-
Authorization:
|
|
69
|
+
Authorization: authToken,
|
|
55
70
|
'Content-Type': 'application/json',
|
|
56
71
|
...attributionHeaders,
|
|
57
72
|
},
|
|
@@ -63,13 +78,8 @@ class GraphApiClient {
|
|
|
63
78
|
return response;
|
|
64
79
|
}
|
|
65
80
|
catch (err) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (scopedActions.length > 0) {
|
|
69
|
-
incrementAuthorizationError(scopeToResource(scopedActions[0].scope).resourceType, scopedActions[0].action, err.status, 'graph');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
throw err;
|
|
81
|
+
// handleApiError never returns (throws)
|
|
82
|
+
return handleApiError(err, 'graph', 'canActionInScopeMultiple');
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
@@ -81,41 +91,39 @@ class GraphApiClient {
|
|
|
81
91
|
const { action, scope } = scopedAction;
|
|
82
92
|
const { resourceType, resourceId } = scopeToResource(scope);
|
|
83
93
|
const permissionResult = resources?.[resourceType]?.[String(resourceId)]?.[action];
|
|
84
|
-
const graphReason = permissionResult?.reason;
|
|
85
|
-
let reasonKey;
|
|
86
|
-
let additionalOptions = {};
|
|
87
|
-
let technicalReason = PermitTechnicalReason.NO_REASON;
|
|
88
|
-
if (typeof graphReason === 'string') {
|
|
89
|
-
reasonKey = graphReason;
|
|
90
|
-
}
|
|
91
|
-
else if (graphReason && typeof graphReason === 'object') {
|
|
92
|
-
reasonKey = graphReason.key ?? 'unknown';
|
|
93
|
-
additionalOptions = graphReason.additionalOptions ?? {};
|
|
94
|
-
if (graphReason.technicalReason !== undefined) {
|
|
95
|
-
technicalReason = (graphReason.technicalReason ?? PermitTechnicalReason.NO_REASON);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
reasonKey = 'unknown';
|
|
100
|
-
}
|
|
101
94
|
const permit = {
|
|
102
95
|
can: permissionResult?.can ?? false,
|
|
103
96
|
reason: {
|
|
104
|
-
key:
|
|
105
|
-
...additionalOptions,
|
|
97
|
+
key: 'unknown',
|
|
106
98
|
},
|
|
107
|
-
technicalReason,
|
|
99
|
+
technicalReason: PermitTechnicalReason.NO_REASON,
|
|
108
100
|
};
|
|
101
|
+
if (permissionResult) {
|
|
102
|
+
const graphReason = GraphApi.ensureGraphReason(permissionResult.reason, { resourceType, resourceId, action });
|
|
103
|
+
permit.reason = {
|
|
104
|
+
key: graphReason.key,
|
|
105
|
+
...(graphReason.additionalOptions ?? {}),
|
|
106
|
+
};
|
|
107
|
+
permit.technicalReason = (graphReason.technicalReason ??
|
|
108
|
+
PermitTechnicalReason.NO_REASON);
|
|
109
|
+
}
|
|
109
110
|
return { scopedAction, permit };
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
/**
|
|
113
114
|
* Performs a complete authorization check using the Graph API
|
|
114
115
|
*/
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
async checkPermissions(accountId, userId, scopedActions) {
|
|
117
|
+
const authToken = signAuthorizationHeader({ appName: this.consumerAppName, accountId, userId });
|
|
118
|
+
const response = await this.fetchPermissions(authToken, scopedActions);
|
|
119
|
+
return GraphApi.mapResponse(scopedActions, response);
|
|
120
|
+
}
|
|
121
|
+
static ensureGraphReason(reason, context) {
|
|
122
|
+
if (!reason || typeof reason !== 'object' || typeof reason.key !== 'string') {
|
|
123
|
+
throw new Error(`GraphApi: unexpected reason format for ${context.resourceType}/${context.resourceId}/${context.action}`);
|
|
124
|
+
}
|
|
125
|
+
return reason;
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
|
|
121
|
-
export {
|
|
129
|
+
export { GraphApi };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScopedAction, ScopedActionResponseObject } from '../types/scoped-actions-contracts';
|
|
2
|
+
import { PlatformProfile } from '../attributions-service';
|
|
3
|
+
/**
|
|
4
|
+
* Client for handling Platform API authorization operations
|
|
5
|
+
*/
|
|
6
|
+
export declare class PlatformApi {
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Builds the request payload for Platform API calls
|
|
11
|
+
*/
|
|
12
|
+
private static buildRequestPayload;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches authorization data from the Platform API
|
|
15
|
+
*/
|
|
16
|
+
private fetchPermissions;
|
|
17
|
+
/**
|
|
18
|
+
* Maps Platform API response to the expected format
|
|
19
|
+
*/
|
|
20
|
+
private static mapResponse;
|
|
21
|
+
/**
|
|
22
|
+
* Performs a complete authorization check using the Platform API
|
|
23
|
+
*/
|
|
24
|
+
checkPermissions(profile: PlatformProfile, internalAuthToken: string, userId: number, scopedActions: ScopedAction[]): Promise<ScopedActionResponseObject[]>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=platform-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-api.d.ts","sourceRoot":"","sources":["../../../src/clients/platform-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,EAA0B,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAelF;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;;IAUxC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAOlC;;OAEG;YACW,gBAAgB;IAqC9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAkB1B;;OAEG;IACG,gBAAgB,CACpB,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;CAKzC"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
-
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
2
|
import { AuthorizationInternalService, logger } from '../authorization-internal-service.mjs';
|
|
4
3
|
import { getAttributionsFromApi } from '../attributions-service.mjs';
|
|
5
|
-
import { toSnakeCase,
|
|
6
|
-
import {
|
|
4
|
+
import { toSnakeCase, toCamelCase } from '../utils/authorization.utils.mjs';
|
|
5
|
+
import { handleApiError } from '../utils/api-error-handler.mjs';
|
|
7
6
|
|
|
8
7
|
const PLATFORM_CAN_ACTIONS_IN_SCOPES_PATH = '/internal_ms/authorization/can_actions_in_scopes';
|
|
9
8
|
/**
|
|
10
9
|
* Client for handling Platform API authorization operations
|
|
11
10
|
*/
|
|
12
|
-
class
|
|
11
|
+
class PlatformApi {
|
|
12
|
+
httpClient;
|
|
13
|
+
constructor() {
|
|
14
|
+
const httpClient = Api.getPart('httpClient');
|
|
15
|
+
if (!httpClient) {
|
|
16
|
+
throw new Error('PlatformApi: http client is not initialized');
|
|
17
|
+
}
|
|
18
|
+
this.httpClient = httpClient;
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
21
|
* Builds the request payload for Platform API calls
|
|
15
22
|
*/
|
|
@@ -22,11 +29,10 @@ class PlatformApiClient {
|
|
|
22
29
|
/**
|
|
23
30
|
* Fetches authorization data from the Platform API
|
|
24
31
|
*/
|
|
25
|
-
|
|
32
|
+
async fetchPermissions(profile, internalAuthToken, userId, scopedActionsPayload) {
|
|
26
33
|
const attributionHeaders = getAttributionsFromApi();
|
|
27
|
-
const httpClient = Api.getPart('httpClient');
|
|
28
34
|
try {
|
|
29
|
-
const response = await httpClient.fetch({
|
|
35
|
+
const response = await this.httpClient.fetch({
|
|
30
36
|
url: {
|
|
31
37
|
appName: 'platform',
|
|
32
38
|
path: PLATFORM_CAN_ACTIONS_IN_SCOPES_PATH,
|
|
@@ -46,14 +52,8 @@ class PlatformApiClient {
|
|
|
46
52
|
return response;
|
|
47
53
|
}
|
|
48
54
|
catch (err) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (scopedActionsPayload.length > 0) {
|
|
52
|
-
const { resourceType } = scopeToResource(toCamelCase(scopedActionsPayload[0].scope));
|
|
53
|
-
incrementAuthorizationError(resourceType, scopedActionsPayload[0].action, err.status, 'platform');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw err;
|
|
55
|
+
// handleApiError never returns (throws)
|
|
56
|
+
return handleApiError(err, 'platform', 'canActionInScopeMultiple');
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
@@ -61,8 +61,8 @@ class PlatformApiClient {
|
|
|
61
61
|
*/
|
|
62
62
|
static mapResponse(response) {
|
|
63
63
|
if (!response) {
|
|
64
|
-
logger.error({ tag: 'platform-api
|
|
65
|
-
throw new Error('
|
|
64
|
+
logger.error({ tag: 'platform-api', response }, 'PlatformApi: missing response');
|
|
65
|
+
throw new Error('PlatformApi: missing response');
|
|
66
66
|
}
|
|
67
67
|
return response.result.map(responseObject => {
|
|
68
68
|
const { scopedAction, permit } = responseObject;
|
|
@@ -77,11 +77,11 @@ class PlatformApiClient {
|
|
|
77
77
|
/**
|
|
78
78
|
* Performs a complete authorization check using the Platform API
|
|
79
79
|
*/
|
|
80
|
-
|
|
81
|
-
const scopedActionsPayload =
|
|
80
|
+
async checkPermissions(profile, internalAuthToken, userId, scopedActions) {
|
|
81
|
+
const scopedActionsPayload = PlatformApi.buildRequestPayload(scopedActions);
|
|
82
82
|
const platformResponse = await this.fetchPermissions(profile, internalAuthToken, userId, scopedActionsPayload);
|
|
83
|
-
return
|
|
83
|
+
return PlatformApi.mapResponse(platformResponse);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export {
|
|
87
|
+
export { PlatformApi };
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
2
|
import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
export declare const APP_NAME = "authorization";
|
|
4
|
+
export declare const GRAPH_APP_NAME = "authorization-graph";
|
|
4
5
|
export declare const ERROR_MESSAGES: {
|
|
5
6
|
readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
|
|
6
7
|
readonly REQUEST_FAILED: (method: string, status: number, reason: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAUjE,CAAC"}
|
package/dist/esm/constants.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const APP_NAME = 'authorization';
|
|
2
|
+
const GRAPH_APP_NAME = 'authorization-graph';
|
|
2
3
|
const ERROR_MESSAGES = {
|
|
3
4
|
HTTP_CLIENT_NOT_INITIALIZED: 'MondayAuthorization: HTTP client is not initialized',
|
|
4
5
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
@@ -15,4 +16,4 @@ const DEFAULT_FETCH_OPTIONS = {
|
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES };
|
|
19
|
+
export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES, GRAPH_APP_NAME };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,12 +5,19 @@ export interface InitOptions {
|
|
|
5
5
|
mondayFetchOptions?: MondayFetchOptions;
|
|
6
6
|
redisClient?: any;
|
|
7
7
|
grantedFeatureRedisExpirationInSeconds?: number;
|
|
8
|
+
metrics?: {
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
host?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
15
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
10
16
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
11
17
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
12
18
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
13
19
|
export { RolesService } from './roles-service';
|
|
20
|
+
export { MembershipsService } from './memberships';
|
|
14
21
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
|
15
22
|
export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
|
|
16
23
|
export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,E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.mjs';
|
|
2
2
|
import { setRequestFetchOptions, setRedisClient, setIgniteClient } from './authorization-service.mjs';
|
|
3
3
|
export { AuthorizationService } from './authorization-service.mjs';
|
|
4
|
+
import { initializeMetrics } from './metrics-service.mjs';
|
|
4
5
|
import * as testKit_index from './testKit/index.mjs';
|
|
5
6
|
export { testKit_index as TestKit };
|
|
6
7
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
|
|
7
8
|
export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
|
|
8
9
|
export { RolesService } from './roles-service.mjs';
|
|
10
|
+
export { MembershipsService } from './memberships.mjs';
|
|
9
11
|
export { RoleType } from './types/roles.mjs';
|
|
10
12
|
|
|
11
13
|
async function init(options = {}) {
|
|
12
14
|
if (options.prometheus) {
|
|
13
15
|
setPrometheus(options.prometheus);
|
|
14
16
|
}
|
|
17
|
+
const resolvedDisabled = options.metrics?.disabled ?? ['test', 'development'].includes((process.env.NODE_ENV ?? '').toLowerCase());
|
|
18
|
+
initializeMetrics({
|
|
19
|
+
serviceName: options.metrics?.serviceName ?? process.env.APP_NAME ?? 'authorization-sdk',
|
|
20
|
+
host: options.metrics?.host,
|
|
21
|
+
port: options.metrics?.port,
|
|
22
|
+
disabled: resolvedDisabled,
|
|
23
|
+
});
|
|
15
24
|
if (options.mondayFetchOptions) {
|
|
16
25
|
setRequestFetchOptions(options.mondayFetchOptions);
|
|
17
26
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
+
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
+
import { MembershipCreateResponse, MembershipDeleteResponse, MembershipForCreate, MembershipForDelete } from './types/memberships';
|
|
4
|
+
export declare class MembershipsService {
|
|
5
|
+
private static API_PATHS;
|
|
6
|
+
private httpClient;
|
|
7
|
+
private fetchOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
10
|
+
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
11
|
+
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
12
|
+
*/
|
|
13
|
+
constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
|
|
14
|
+
/**
|
|
15
|
+
* Upsert memberships synchronously, performing http call to the authorization MS to assign the given memberships.
|
|
16
|
+
* @param accountId
|
|
17
|
+
* @param memberships - Array of memberships to upsert
|
|
18
|
+
* @returns MembershipCreateResponse - The affected (created and updated) memberships.
|
|
19
|
+
*/
|
|
20
|
+
upsertMemberships(accountId: number, memberships: MembershipForCreate[]): Promise<MembershipCreateResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Delete memberships synchronously, performing http call to the authorization MS to delete the given memberships.
|
|
23
|
+
* @param accountId
|
|
24
|
+
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
25
|
+
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
26
|
+
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
27
|
+
*/
|
|
28
|
+
deleteMemberships(accountId: number, memberships: MembershipForDelete[]): Promise<MembershipDeleteResponse>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=memberships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memberships.d.ts","sourceRoot":"","sources":["../../src/memberships.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAGb;IACX,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAkC;IAEtD;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAoBnF;;;;;OAKG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA0BjH;;;;;;OAMG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAyBlH"}
|