@mondaydotcomorg/monday-authorization 3.3.0-feature-bashanye-navigate-can-action-in-scope-to-graph-849b734 → 3.3.0-feature-bashanye-navigate-can-action-in-scope-to-graph-36f311f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +7 -0
- package/dist/clients/graph-api.client.d.ts.map +1 -1
- package/dist/clients/graph-api.client.js +37 -2
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +7 -0
- package/dist/esm/clients/graph-api.client.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.client.mjs +37 -2
- package/dist/esm/types/graph-api.types.d.ts +9 -1
- package/dist/esm/types/graph-api.types.d.ts.map +1 -1
- package/dist/types/graph-api.types.d.ts +9 -1
- package/dist/types/graph-api.types.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/attributions-service.ts +0 -92
- package/src/authorization-attributes-service.ts +0 -234
- package/src/authorization-internal-service.ts +0 -129
- package/src/authorization-middleware.ts +0 -51
- package/src/authorization-service.ts +0 -355
- package/src/clients/graph-api.client.ts +0 -132
- package/src/clients/platform-api.client.ts +0 -116
- package/src/constants/sns.ts +0 -5
- package/src/constants.ts +0 -22
- package/src/index.ts +0 -46
- package/src/prometheus-service.ts +0 -147
- package/src/roles-service.ts +0 -125
- package/src/testKit/index.ts +0 -69
- package/src/types/authorization-attributes-contracts.ts +0 -33
- package/src/types/express.ts +0 -8
- package/src/types/general.ts +0 -32
- package/src/types/graph-api.types.ts +0 -19
- package/src/types/roles.ts +0 -42
- package/src/types/scoped-actions-contracts.ts +0 -48
- package/src/utils/authorization.utils.ts +0 -47
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface WorkspaceScope {
|
|
2
|
-
workspaceId: number;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface BoardScope {
|
|
6
|
-
boardId: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface PulseScope {
|
|
10
|
-
pulseId: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface AccountProductScope {
|
|
14
|
-
accountProductId: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AccountScope {
|
|
18
|
-
accountId: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
22
|
-
|
|
23
|
-
export interface Translation {
|
|
24
|
-
key: string;
|
|
25
|
-
[option: string]: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export enum PermitTechnicalReason {
|
|
29
|
-
NO_REASON = 0,
|
|
30
|
-
NOT_ELIGIBLE = 1,
|
|
31
|
-
BY_ROLE_IN_SCOPE = 2,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface ScopedActionPermit {
|
|
35
|
-
can: boolean;
|
|
36
|
-
reason: Translation;
|
|
37
|
-
technicalReason: PermitTechnicalReason;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ScopedAction {
|
|
41
|
-
action: string;
|
|
42
|
-
scope: ScopeOptions;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ScopedActionResponseObject {
|
|
46
|
-
scopedAction: ScopedAction;
|
|
47
|
-
permit: ScopedActionPermit;
|
|
48
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import snakeCase from 'lodash/snakeCase.js';
|
|
2
|
-
import camelCase from 'lodash/camelCase.js';
|
|
3
|
-
import mapKeys from 'lodash/mapKeys.js';
|
|
4
|
-
import { ScopeOptions } from '../types/scoped-actions-contracts';
|
|
5
|
-
import { ResourceType, ResourceId } from '../types/graph-api.types';
|
|
6
|
-
|
|
7
|
-
export type CamelCase<S extends string> = S extends `${infer F}_${infer R}` ? `${F}${Capitalize<CamelCase<R>>}` : S;
|
|
8
|
-
export type CamelCaseKeys<T> = T extends object
|
|
9
|
-
? { [K in keyof T as K extends string ? CamelCase<K> : K]: CamelCaseKeys<T[K]> }
|
|
10
|
-
: T;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Converts a scope object to resource type and resource ID
|
|
14
|
-
*/
|
|
15
|
-
export function scopeToResource(scope: ScopeOptions): { resourceType: ResourceType; resourceId: ResourceId } {
|
|
16
|
-
if ('workspaceId' in scope) {
|
|
17
|
-
return { resourceType: 'workspace', resourceId: scope.workspaceId };
|
|
18
|
-
}
|
|
19
|
-
if ('boardId' in scope) {
|
|
20
|
-
return { resourceType: 'board', resourceId: scope.boardId };
|
|
21
|
-
}
|
|
22
|
-
if ('pulseId' in scope) {
|
|
23
|
-
return { resourceType: 'pulse', resourceId: scope.pulseId };
|
|
24
|
-
}
|
|
25
|
-
if ('accountProductId' in scope) {
|
|
26
|
-
return { resourceType: 'account_product', resourceId: scope.accountProductId };
|
|
27
|
-
}
|
|
28
|
-
if ('accountId' in scope) {
|
|
29
|
-
return { resourceType: 'account', resourceId: scope.accountId };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
throw new Error('Unsupported scope provided');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Converts object keys from snake_case to camelCase
|
|
37
|
-
*/
|
|
38
|
-
export function toCamelCase<T extends object>(obj: T): CamelCaseKeys<T> {
|
|
39
|
-
return mapKeys(obj, (_, key) => camelCase(key)) as CamelCaseKeys<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Converts object keys from camelCase to snake_case
|
|
44
|
-
*/
|
|
45
|
-
export function toSnakeCase<T extends object>(obj: T): Record<string, any> {
|
|
46
|
-
return mapKeys(obj, (_, key) => snakeCase(key));
|
|
47
|
-
}
|