@mondaydotcomorg/monday-authorization 3.9.4 → 3.9.5
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 +2 -0
- package/dist/authorization-service.d.ts +4 -1
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +16 -4
- package/dist/esm/authorization-service.d.ts +4 -1
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +16 -4
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/validation.d.ts +0 -3
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +7 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/validation.d.ts +0 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +7 -5
- package/package.json +1 -1
- package/src/authorization-service.ts +31 -4
- package/src/index.ts +6 -1
- package/src/utils/validation.ts +9 -2
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ startServer(...)
|
|
|
42
42
|
- metrics - (optional), configure internal DataDog/observability integration. Provide either:
|
|
43
43
|
- `metrics.client` with a pre-initialized StatsD client that exposes `distribution` and `increment`.
|
|
44
44
|
- Or the config fields (`serviceName`, `host`, `port`, `disabled`) to let the SDK initialize `@mondaydotcomorg/monday-observability-kit` for you. Defaults to `process.env.APP_NAME` as the service name, uses the standard StatsD endpoint (`localhost:8125`) when host/port are not provided, and disables emission automatically in test/development environments (override with `disabled`).
|
|
45
|
+
- ignite - (optional), configure Ignite usage for gradual release flags:
|
|
46
|
+
- `ignite.client` to reuse an already initialized Ignite client from your service (recommended).
|
|
45
47
|
|
|
46
48
|
### Metrics & Observability
|
|
47
49
|
|
|
@@ -38,6 +38,9 @@ export declare class AuthorizationService {
|
|
|
38
38
|
private static isAuthorizedMultiple;
|
|
39
39
|
}
|
|
40
40
|
export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
|
|
41
|
-
export
|
|
41
|
+
export interface IgniteClientInitOptions {
|
|
42
|
+
client?: IgniteClient;
|
|
43
|
+
}
|
|
44
|
+
export declare function setIgniteClient(options?: IgniteClientInitOptions): Promise<void>;
|
|
42
45
|
export declare function createAuthorizationParams(resources: AuthorizationResource[], action: Action): AuthorizationParams;
|
|
43
46
|
//# sourceMappingURL=authorization-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG1G,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,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,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG1G,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAa1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EA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AAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAUD,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,uBAAuB,iBAoBtE;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
|
|
@@ -15,6 +15,7 @@ const utils_authorization_utils = require('./utils/authorization.utils.js');
|
|
|
15
15
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
16
16
|
const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
17
17
|
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
18
|
+
const AUTHORIZATION_SDK_IGNITE_NAMESPACE = 'authorization-sdk';
|
|
18
19
|
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
19
20
|
authorizationInternalService.AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
20
21
|
}
|
|
@@ -194,10 +195,21 @@ function setRedisClient(client, grantedFeatureRedisExpirationInSeconds = GRANTED
|
|
|
194
195
|
AuthorizationService.grantedFeatureRedisExpirationInSeconds = GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
function canRegisterNamespaces(client) {
|
|
199
|
+
return typeof client.registerNamespaces === 'function';
|
|
200
|
+
}
|
|
201
|
+
async function setIgniteClient(options) {
|
|
202
|
+
const namespaces = [AUTHORIZATION_SDK_IGNITE_NAMESPACE];
|
|
203
|
+
const igniteClient = options?.client ??
|
|
204
|
+
(await igniteSdk.getIgniteClient({
|
|
205
|
+
namespace: namespaces,
|
|
206
|
+
}));
|
|
207
|
+
if (options?.client) {
|
|
208
|
+
if (!canRegisterNamespaces(igniteClient)) {
|
|
209
|
+
throw new Error('AuthorizationService: ignite client must support namespace registration (registerNamespaces) when passing ignite.client');
|
|
210
|
+
}
|
|
211
|
+
await igniteClient.registerNamespaces(namespaces);
|
|
212
|
+
}
|
|
201
213
|
AuthorizationService.igniteClient = igniteClient;
|
|
202
214
|
authorizationInternalService.AuthorizationInternalService.setIgniteClient(igniteClient);
|
|
203
215
|
}
|
|
@@ -38,6 +38,9 @@ export declare class AuthorizationService {
|
|
|
38
38
|
private static isAuthorizedMultiple;
|
|
39
39
|
}
|
|
40
40
|
export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
|
|
41
|
-
export
|
|
41
|
+
export interface IgniteClientInitOptions {
|
|
42
|
+
client?: IgniteClient;
|
|
43
|
+
}
|
|
44
|
+
export declare function setIgniteClient(options?: IgniteClientInitOptions): Promise<void>;
|
|
42
45
|
export declare function createAuthorizationParams(resources: AuthorizationResource[], action: Action): AuthorizationParams;
|
|
43
46
|
//# sourceMappingURL=authorization-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG1G,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src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SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;WAMjB,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,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAUD,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,uBAAuB,iBAoBtE;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
|
|
@@ -13,6 +13,7 @@ import { scopeToResource } from './utils/authorization.utils.mjs';
|
|
|
13
13
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
14
14
|
const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
15
15
|
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
16
|
+
const AUTHORIZATION_SDK_IGNITE_NAMESPACE = 'authorization-sdk';
|
|
16
17
|
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
17
18
|
AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
18
19
|
}
|
|
@@ -192,10 +193,21 @@ function setRedisClient(client, grantedFeatureRedisExpirationInSeconds = GRANTED
|
|
|
192
193
|
AuthorizationService.grantedFeatureRedisExpirationInSeconds = GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS;
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
function canRegisterNamespaces(client) {
|
|
197
|
+
return typeof client.registerNamespaces === 'function';
|
|
198
|
+
}
|
|
199
|
+
async function setIgniteClient(options) {
|
|
200
|
+
const namespaces = [AUTHORIZATION_SDK_IGNITE_NAMESPACE];
|
|
201
|
+
const igniteClient = options?.client ??
|
|
202
|
+
(await getIgniteClient({
|
|
203
|
+
namespace: namespaces,
|
|
204
|
+
}));
|
|
205
|
+
if (options?.client) {
|
|
206
|
+
if (!canRegisterNamespaces(igniteClient)) {
|
|
207
|
+
throw new Error('AuthorizationService: ignite client must support namespace registration (registerNamespaces) when passing ignite.client');
|
|
208
|
+
}
|
|
209
|
+
await igniteClient.registerNamespaces(namespaces);
|
|
210
|
+
}
|
|
199
211
|
AuthorizationService.igniteClient = igniteClient;
|
|
200
212
|
AuthorizationInternalService.setIgniteClient(igniteClient);
|
|
201
213
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
2
|
import { MetricsClient } from './metrics-service';
|
|
3
3
|
import * as TestKit from './testKit';
|
|
4
|
+
import type { IgniteClientInitOptions } from './authorization-service';
|
|
4
5
|
interface MetricsInitOptions {
|
|
5
6
|
client?: MetricsClient;
|
|
6
7
|
serviceName?: string;
|
|
@@ -8,12 +9,14 @@ interface MetricsInitOptions {
|
|
|
8
9
|
port?: number;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
}
|
|
12
|
+
export type { IgniteClientInitOptions } from './authorization-service';
|
|
11
13
|
export interface InitOptions {
|
|
12
14
|
prometheus?: any;
|
|
13
15
|
mondayFetchOptions?: MondayFetchOptions;
|
|
14
16
|
redisClient?: any;
|
|
15
17
|
grantedFeatureRedisExpirationInSeconds?: number;
|
|
16
18
|
metrics?: MetricsInitOptions;
|
|
19
|
+
ignite?: IgniteClientInitOptions;
|
|
17
20
|
}
|
|
18
21
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
19
22
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
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;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO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BAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,IAAI,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,GAC/D,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -41,7 +41,7 @@ async function init(options = {}) {
|
|
|
41
41
|
setRedisClient(options.redisClient, options.grantedFeatureRedisExpirationInSeconds);
|
|
42
42
|
}
|
|
43
43
|
// add an ignite client for gradual release features
|
|
44
|
-
await setIgniteClient();
|
|
44
|
+
await setIgniteClient(options.ignite);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { init };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ResourceAttributeAssignment, EntityAttributeAssignment, ResourceAttributeDeleteAssignment, EntityAttributeDeleteAssignment } from '../types/authorization-attributes-contracts';
|
|
2
2
|
import { Resource } from '../types/general';
|
|
3
|
-
/**
|
|
4
|
-
* Utility class for common validation operations using AJV
|
|
5
|
-
*/
|
|
6
3
|
export declare class ValidationUtils {
|
|
7
4
|
private static ajv;
|
|
8
5
|
private static integerValidator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAc5C,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAElD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAyE;IACxG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAwE;IACtG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAGhC;WAEW,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOpC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;WAO1C,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAQjD;;;OAGG;IACH,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAYnF,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,iCAAiC,GAAG,IAAI;IAYzF,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAU7E,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,+BAA+B,GAAG,IAAI;IASnF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAmBtC"}
|
|
@@ -3,9 +3,6 @@ import { ArgumentError } from '../errors/argument-error.mjs';
|
|
|
3
3
|
import { resourceUpsertAssignmentSchema, resourceDeleteAssignmentSchema, entityUpsertAssignmentSchema, entityDeleteAssignmentSchema } from './assignment-schema.mjs';
|
|
4
4
|
import { resourceSchema } from './resource-schema.mjs';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Utility class for common validation operations using AJV
|
|
8
|
-
*/
|
|
9
6
|
class ValidationUtils {
|
|
10
7
|
static ajv = new Ajv({ allErrors: true });
|
|
11
8
|
static integerValidator = this.ajv.compile({ type: 'number', multipleOf: 1 });
|
|
@@ -84,8 +81,13 @@ class ValidationUtils {
|
|
|
84
81
|
}
|
|
85
82
|
return errors
|
|
86
83
|
.map(err => {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
84
|
+
const errorWithDataPath = err;
|
|
85
|
+
const path = errorWithDataPath.instancePath ||
|
|
86
|
+
errorWithDataPath.dataPath ||
|
|
87
|
+
(errorWithDataPath.params && 'missingProperty' in errorWithDataPath.params
|
|
88
|
+
? `/${errorWithDataPath.params.missingProperty}`
|
|
89
|
+
: '');
|
|
90
|
+
const message = errorWithDataPath.message || 'validation failed';
|
|
89
91
|
return path ? `${path}: ${message}` : message;
|
|
90
92
|
})
|
|
91
93
|
.join('; ');
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
2
|
import { MetricsClient } from './metrics-service';
|
|
3
3
|
import * as TestKit from './testKit';
|
|
4
|
+
import type { IgniteClientInitOptions } from './authorization-service';
|
|
4
5
|
interface MetricsInitOptions {
|
|
5
6
|
client?: MetricsClient;
|
|
6
7
|
serviceName?: string;
|
|
@@ -8,12 +9,14 @@ interface MetricsInitOptions {
|
|
|
8
9
|
port?: number;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
}
|
|
12
|
+
export type { IgniteClientInitOptions } from './authorization-service';
|
|
11
13
|
export interface InitOptions {
|
|
12
14
|
prometheus?: any;
|
|
13
15
|
mondayFetchOptions?: MondayFetchOptions;
|
|
14
16
|
redisClient?: any;
|
|
15
17
|
grantedFeatureRedisExpirationInSeconds?: number;
|
|
16
18
|
metrics?: MetricsInitOptions;
|
|
19
|
+
ignite?: IgniteClientInitOptions;
|
|
17
20
|
}
|
|
18
21
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
19
22
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
package/dist/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;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IAC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,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,IAAI,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,GAC/D,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ async function init(options = {}) {
|
|
|
41
41
|
authorizationService.setRedisClient(options.redisClient, options.grantedFeatureRedisExpirationInSeconds);
|
|
42
42
|
}
|
|
43
43
|
// add an ignite client for gradual release features
|
|
44
|
-
await authorizationService.setIgniteClient();
|
|
44
|
+
await authorizationService.setIgniteClient(options.ignite);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
exports.AuthorizationService = authorizationService.AuthorizationService;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ResourceAttributeAssignment, EntityAttributeAssignment, ResourceAttributeDeleteAssignment, EntityAttributeDeleteAssignment } from '../types/authorization-attributes-contracts';
|
|
2
2
|
import { Resource } from '../types/general';
|
|
3
|
-
/**
|
|
4
|
-
* Utility class for common validation operations using AJV
|
|
5
|
-
*/
|
|
6
3
|
export declare class ValidationUtils {
|
|
7
4
|
private static ajv;
|
|
8
5
|
private static integerValidator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAc5C,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAElD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAyE;IACxG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAwE;IACtG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAGhC;WAEW,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOpC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;WAO1C,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAQjD;;;OAGG;IACH,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAYnF,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,iCAAiC,GAAG,IAAI;IAYzF,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAU7E,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,+BAA+B,GAAG,IAAI;IASnF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAmBtC"}
|
package/dist/utils/validation.js
CHANGED
|
@@ -9,9 +9,6 @@ const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
|
9
9
|
|
|
10
10
|
const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Utility class for common validation operations using AJV
|
|
14
|
-
*/
|
|
15
12
|
class ValidationUtils {
|
|
16
13
|
static ajv = new Ajv__default.default({ allErrors: true });
|
|
17
14
|
static integerValidator = this.ajv.compile({ type: 'number', multipleOf: 1 });
|
|
@@ -90,8 +87,13 @@ class ValidationUtils {
|
|
|
90
87
|
}
|
|
91
88
|
return errors
|
|
92
89
|
.map(err => {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
90
|
+
const errorWithDataPath = err;
|
|
91
|
+
const path = errorWithDataPath.instancePath ||
|
|
92
|
+
errorWithDataPath.dataPath ||
|
|
93
|
+
(errorWithDataPath.params && 'missingProperty' in errorWithDataPath.params
|
|
94
|
+
? `/${errorWithDataPath.params.missingProperty}`
|
|
95
|
+
: '');
|
|
96
|
+
const message = errorWithDataPath.message || 'validation failed';
|
|
95
97
|
return path ? `${path}: ${message}` : message;
|
|
96
98
|
})
|
|
97
99
|
.join('; ');
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
|
22
22
|
const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
23
23
|
|
|
24
24
|
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
25
|
+
const AUTHORIZATION_SDK_IGNITE_NAMESPACE = 'authorization-sdk';
|
|
25
26
|
|
|
26
27
|
export interface AuthorizeResponse {
|
|
27
28
|
isAuthorized: boolean;
|
|
@@ -305,10 +306,36 @@ export function setRedisClient(
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
|
|
308
|
-
export
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
export interface IgniteClientInitOptions {
|
|
310
|
+
client?: IgniteClient;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
type IgniteClientWithNamespaceRegistration = IgniteClient & {
|
|
314
|
+
registerNamespaces(newNamespaces: string[]): Promise<void>;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
function canRegisterNamespaces(client: IgniteClient): client is IgniteClientWithNamespaceRegistration {
|
|
318
|
+
return typeof (client as IgniteClientWithNamespaceRegistration).registerNamespaces === 'function';
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export async function setIgniteClient(options?: IgniteClientInitOptions) {
|
|
322
|
+
const namespaces = [AUTHORIZATION_SDK_IGNITE_NAMESPACE];
|
|
323
|
+
|
|
324
|
+
const igniteClient =
|
|
325
|
+
options?.client ??
|
|
326
|
+
(await getIgniteClient({
|
|
327
|
+
namespace: namespaces,
|
|
328
|
+
}));
|
|
329
|
+
|
|
330
|
+
if (options?.client) {
|
|
331
|
+
if (!canRegisterNamespaces(igniteClient)) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
'AuthorizationService: ignite client must support namespace registration (registerNamespaces) when passing ignite.client'
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
await igniteClient.registerNamespaces(namespaces);
|
|
337
|
+
}
|
|
338
|
+
|
|
312
339
|
AuthorizationService.igniteClient = igniteClient;
|
|
313
340
|
AuthorizationInternalService.setIgniteClient(igniteClient);
|
|
314
341
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { setIgniteClient, setRedisClient, setRequestFetchOptions } from './autho
|
|
|
4
4
|
import { initializeMetrics, MetricsClient } from './metrics-service';
|
|
5
5
|
import * as TestKit from './testKit';
|
|
6
6
|
|
|
7
|
+
import type { IgniteClientInitOptions } from './authorization-service';
|
|
8
|
+
|
|
7
9
|
interface MetricsInitOptions {
|
|
8
10
|
client?: MetricsClient;
|
|
9
11
|
serviceName?: string;
|
|
@@ -12,12 +14,15 @@ interface MetricsInitOptions {
|
|
|
12
14
|
disabled?: boolean;
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
export type { IgniteClientInitOptions } from './authorization-service';
|
|
18
|
+
|
|
15
19
|
export interface InitOptions {
|
|
16
20
|
prometheus?: any;
|
|
17
21
|
mondayFetchOptions?: MondayFetchOptions;
|
|
18
22
|
redisClient?: any;
|
|
19
23
|
grantedFeatureRedisExpirationInSeconds?: number;
|
|
20
24
|
metrics?: MetricsInitOptions;
|
|
25
|
+
ignite?: IgniteClientInitOptions;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export async function init(options: InitOptions = {}) {
|
|
@@ -48,7 +53,7 @@ export async function init(options: InitOptions = {}) {
|
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
// add an ignite client for gradual release features
|
|
51
|
-
await setIgniteClient();
|
|
56
|
+
await setIgniteClient(options.ignite);
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
export {
|
package/src/utils/validation.ts
CHANGED
|
@@ -18,6 +18,8 @@ import { resourceSchema } from './resource-schema';
|
|
|
18
18
|
/**
|
|
19
19
|
* Utility class for common validation operations using AJV
|
|
20
20
|
*/
|
|
21
|
+
type ErrorObjectWithDataPath = ErrorObject & { dataPath?: string; instancePath?: string };
|
|
22
|
+
|
|
21
23
|
export class ValidationUtils {
|
|
22
24
|
private static ajv = new Ajv({ allErrors: true });
|
|
23
25
|
|
|
@@ -114,9 +116,14 @@ export class ValidationUtils {
|
|
|
114
116
|
|
|
115
117
|
return errors
|
|
116
118
|
.map(err => {
|
|
119
|
+
const errorWithDataPath = err as ErrorObjectWithDataPath;
|
|
117
120
|
const path =
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
errorWithDataPath.instancePath ||
|
|
122
|
+
errorWithDataPath.dataPath ||
|
|
123
|
+
(errorWithDataPath.params && 'missingProperty' in errorWithDataPath.params
|
|
124
|
+
? `/${errorWithDataPath.params.missingProperty}`
|
|
125
|
+
: '');
|
|
126
|
+
const message = errorWithDataPath.message || 'validation failed';
|
|
120
127
|
return path ? `${path}: ${message}` : message;
|
|
121
128
|
})
|
|
122
129
|
.join('; ');
|