@mondaydotcomorg/monday-authorization 3.9.2 → 3.9.4-feat-shaime-fix-timeout-53ee888
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 -62
- package/dist/authorization-internal-service.d.ts +4 -0
- package/dist/authorization-internal-service.d.ts.map +1 -1
- package/dist/authorization-internal-service.js +32 -19
- package/dist/authorization-service.d.ts +1 -1
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -5
- package/dist/esm/authorization-internal-service.d.ts +4 -0
- package/dist/esm/authorization-internal-service.d.ts.map +1 -1
- package/dist/esm/authorization-internal-service.mjs +32 -19
- package/dist/esm/authorization-service.d.ts +1 -1
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +0 -5
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/memberships.mjs +5 -5
- package/dist/esm/roles-service.mjs +1 -1
- package/dist/esm/types/scoped-actions-contracts.d.ts +1 -4
- package/dist/esm/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/esm/utils/authorization.utils.d.ts.map +1 -1
- package/dist/esm/utils/authorization.utils.mjs +0 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/memberships.js +5 -5
- package/dist/roles-service.js +1 -1
- package/dist/types/scoped-actions-contracts.d.ts +1 -4
- package/dist/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/utils/authorization.utils.d.ts.map +1 -1
- package/dist/utils/authorization.utils.js +0 -3
- package/package.json +2 -2
- package/src/authorization-internal-service.ts +47 -19
- package/src/authorization-service.ts +1 -1
- package/src/constants.ts +0 -5
- package/src/index.ts +1 -3
- package/src/memberships.ts +5 -5
- package/src/roles-service.ts +1 -1
- package/src/types/scoped-actions-contracts.ts +1 -11
- package/src/utils/authorization.utils.ts +0 -3
package/README.md
CHANGED
|
@@ -31,11 +31,7 @@ await MondayAuthorization.init({
|
|
|
31
31
|
serviceName: process.env.APP_NAME,
|
|
32
32
|
},
|
|
33
33
|
redisClient: redisClient,
|
|
34
|
-
grantedFeatureRedisExpirationInSeconds: 10 * 60
|
|
35
|
-
mondayFetchOptions: {
|
|
36
|
-
maxRetries: 5,
|
|
37
|
-
retryDelayMS: 100,
|
|
38
|
-
},
|
|
34
|
+
grantedFeatureRedisExpirationInSeconds: 10 * 60
|
|
39
35
|
});
|
|
40
36
|
startServer(...)
|
|
41
37
|
```
|
|
@@ -538,70 +534,14 @@ interface MembershipDeleteResponse {
|
|
|
538
534
|
}
|
|
539
535
|
```
|
|
540
536
|
|
|
541
|
-
### Retry Configuration (v4.0.0+)
|
|
542
|
-
|
|
543
|
-
Retry behavior is configurable via Ignite SDK. Configure the `authorization_retry_config` key in Ignite:
|
|
544
|
-
|
|
545
|
-
```json
|
|
546
|
-
{
|
|
547
|
-
"maxRetries": 3,
|
|
548
|
-
"baseDelayMs": 20,
|
|
549
|
-
"exponentBase": 2,
|
|
550
|
-
"jitterMinMs": 0,
|
|
551
|
-
"jitterMaxMs": 1000,
|
|
552
|
-
"retryOnStatusPatterns": ["429", "5**"]
|
|
553
|
-
}
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
**Configuration Options:**
|
|
557
|
-
- `maxRetries`: Maximum number of retry attempts (default: 3)
|
|
558
|
-
- `baseDelayMs`: Base delay in milliseconds for exponential backoff (default: 20)
|
|
559
|
-
- `exponentBase`: Base for exponential backoff calculation (default: 2)
|
|
560
|
-
- `jitterMinMs`: Minimum jitter value in milliseconds (default: 0)
|
|
561
|
-
- `jitterMaxMs`: Maximum jitter value in milliseconds (default: 1000)
|
|
562
|
-
- `retryOnStatusPatterns`: Array of status code patterns to retry on
|
|
563
|
-
- Exact codes: `"429"` (retry on 429)
|
|
564
|
-
- Wildcards: `"5**"` (retry on all 5xx errors), `"5*9"` (retry on 509, 519, 529, etc.)
|
|
565
|
-
|
|
566
|
-
**Retry Delay Formula:**
|
|
567
|
-
```
|
|
568
|
-
delay = baseDelayMs * (exponentBase ^ (attemptCount - 1)) + random(jitterMinMs, jitterMaxMs)
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
**Timeout Configuration:**
|
|
572
|
-
- Configure timeout via `outgoing-request-timeout-ms` Ignite key (default: 2000ms in production, 60000ms in development)
|
|
573
|
-
- Per-service overrides via `override-outgoing-request-timeout-ms` object keyed by `APP_NAME`
|
|
574
|
-
|
|
575
|
-
**Programmatic Configuration:**
|
|
576
|
-
You can also configure retry behavior programmatically via `mondayFetchOptions` in `init()`:
|
|
577
|
-
|
|
578
|
-
```ts
|
|
579
|
-
import { init, AuthorizationFetchOptions } from '@mondaydotcomorg/monday-authorization';
|
|
580
|
-
|
|
581
|
-
const fetchOptions: AuthorizationFetchOptions = {
|
|
582
|
-
maxRetries: 5,
|
|
583
|
-
retryDelayMS: 100,
|
|
584
|
-
retryOn: (attempt, error, response, isTimeoutError) => {
|
|
585
|
-
// Custom retry logic
|
|
586
|
-
return isTimeoutError || (response?.status === 429);
|
|
587
|
-
},
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
await init({
|
|
591
|
-
mondayFetchOptions: fetchOptions,
|
|
592
|
-
// ... other options
|
|
593
|
-
});
|
|
594
|
-
```
|
|
595
|
-
|
|
596
537
|
## Development
|
|
597
538
|
|
|
598
539
|
### Local Development and Testing
|
|
599
540
|
|
|
600
541
|
This package includes an `ignite-local-overrides.json` file for local development and testing only. It does **not** affect consumers of this package - they use their own Ignite configuration.
|
|
601
542
|
|
|
602
|
-
The file enables feature flags
|
|
543
|
+
The file enables feature flags for testing:
|
|
603
544
|
|
|
604
545
|
- `navigate-can-action-in-scope-to-graph`: Graph API routing for `canActionInScope` methods
|
|
605
|
-
- `authorization_retry_config`: Retry configuration for testing (see Retry Configuration section above)
|
|
606
546
|
|
|
607
547
|
Modify this file for different local test scenarios, but remember changes only affect this package's development/testing.
|
|
@@ -5,6 +5,9 @@ import type { AuthorizationFetchOptions } from './types/fetch-options';
|
|
|
5
5
|
export declare const MAX_RETRIES = 3;
|
|
6
6
|
export declare const RETRY_DELAY_MS = 20;
|
|
7
7
|
export declare const logger: import("bunyan");
|
|
8
|
+
/**
|
|
9
|
+
* Key used to retrieve retry configuration from Ignite.
|
|
10
|
+
*/
|
|
8
11
|
export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
|
|
9
12
|
export declare const onRetryCallback: OnRetryCallback;
|
|
10
13
|
/**
|
|
@@ -26,6 +29,7 @@ export declare class AuthorizationInternalService {
|
|
|
26
29
|
static generateInternalAuthToken(accountId: number, userId: number): string;
|
|
27
30
|
static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
|
|
28
31
|
static getRequestFetchOptions(): AuthorizationFetchOptions;
|
|
32
|
+
static resetRequestFetchOptions(): void;
|
|
29
33
|
static setIgniteClient(client: IgniteClient): void;
|
|
30
34
|
static getRequestTimeout(): number;
|
|
31
35
|
static getRetriesPolicy(): RetryPolicy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../src/authorization-internal-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,WAAW,EAEZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAE/C,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-internal-service.d.ts","s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B,EAAE,yBAAyB;IAWjF,MAAM,CAAC,sBAAsB,IAAI,yBAAyB;IAI1D,MAAM,CAAC,wBAAwB;IAI/B,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY;IAI3C,MAAM,CAAC,iBAAiB;IA0BxB,MAAM,CAAC,gBAAgB,IAAI,WAAW;CA2BvC"}
|
|
@@ -27,6 +27,9 @@ const INTERNAL_APP_NAME = 'internal_ms';
|
|
|
27
27
|
const MAX_RETRIES = 3;
|
|
28
28
|
const RETRY_DELAY_MS = 20;
|
|
29
29
|
const logger = MondayLogger__namespace.getLogger();
|
|
30
|
+
/**
|
|
31
|
+
* Key used to retrieve retry configuration from Ignite.
|
|
32
|
+
*/
|
|
30
33
|
const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
|
|
31
34
|
let igniteClient;
|
|
32
35
|
const defaultRetryConfig = {
|
|
@@ -41,11 +44,17 @@ const defaultRetryConfig = {
|
|
|
41
44
|
* Sanitizes retry configuration values to ensure they are within valid ranges
|
|
42
45
|
*/
|
|
43
46
|
function sanitizeRetryConfig(config) {
|
|
47
|
+
const merged = { ...defaultRetryConfig, ...config };
|
|
44
48
|
return {
|
|
45
|
-
...
|
|
46
|
-
retries: Math.max(0, Math.min(5,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
...merged,
|
|
50
|
+
retries: Math.max(0, Math.min(5, merged.retries)),
|
|
51
|
+
baseDelayMs: Math.max(0, merged.baseDelayMs),
|
|
52
|
+
exponentBase: Math.max(1, Math.min(100, merged.exponentBase)),
|
|
53
|
+
jitterMinMs: Math.max(0, merged.jitterMinMs),
|
|
54
|
+
jitterMaxMs: Math.max(0, merged.jitterMaxMs),
|
|
55
|
+
retryOnStatusPatterns: Array.isArray(merged.retryOnStatusPatterns)
|
|
56
|
+
? merged.retryOnStatusPatterns
|
|
57
|
+
: defaultRetryConfig.retryOnStatusPatterns,
|
|
49
58
|
};
|
|
50
59
|
}
|
|
51
60
|
function getRetryConfig() {
|
|
@@ -67,6 +76,10 @@ function randomIntInclusive(min, max) {
|
|
|
67
76
|
}
|
|
68
77
|
return Math.floor(min + Math.random() * (max - min + 1));
|
|
69
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Helper to build status matchers from config patterns.
|
|
81
|
+
* @param patterns Array of patterns like "429", "5**", "5*9"
|
|
82
|
+
*/
|
|
70
83
|
function buildHttpStatusMatchers(patterns) {
|
|
71
84
|
const matchers = [];
|
|
72
85
|
const addWildcardMatcher = (wildcard) => {
|
|
@@ -119,13 +132,6 @@ function buildHttpStatusMatchers(patterns) {
|
|
|
119
132
|
}
|
|
120
133
|
return matchers;
|
|
121
134
|
}
|
|
122
|
-
function shouldRetryOnResponseStatus(responseOrStatus, statusMatchers) {
|
|
123
|
-
const status = responseOrStatus?.status;
|
|
124
|
-
if (typeof status !== 'number') {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return statusMatchers.some(matcher => matcher(status));
|
|
128
|
-
}
|
|
129
135
|
const onRetryCallback = (attempt, error, response, isTimeoutError) => {
|
|
130
136
|
const effectiveMaxRetries = getRetryConfig().retries;
|
|
131
137
|
if (attempt == effectiveMaxRetries) {
|
|
@@ -148,9 +154,7 @@ const calcDelayDurationInMs = ({ attemptCount }) => {
|
|
|
148
154
|
const jitter = randomIntInclusive(jitterMin, jitterMax);
|
|
149
155
|
return expDelay + jitter;
|
|
150
156
|
};
|
|
151
|
-
let mondayFetchOptions = {
|
|
152
|
-
retries: defaultRetryConfig.retries,
|
|
153
|
-
};
|
|
157
|
+
let mondayFetchOptions = {};
|
|
154
158
|
class AuthorizationInternalService {
|
|
155
159
|
static get igniteClient() {
|
|
156
160
|
return igniteClient;
|
|
@@ -166,7 +170,7 @@ class AuthorizationInternalService {
|
|
|
166
170
|
}
|
|
167
171
|
static failIfNotCoveredByAuthorization(request) {
|
|
168
172
|
if (!request.authorizationCheckPerformed && !request.authorizationSkipPerformed) {
|
|
169
|
-
throw 'Endpoint is not covered by authorization check';
|
|
173
|
+
throw new Error('Endpoint is not covered by authorization check');
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
static throwOnHttpErrorIfNeeded(response, placement) {
|
|
@@ -190,13 +194,16 @@ class AuthorizationInternalService {
|
|
|
190
194
|
sanitizedOptions.retries = Math.max(0, Math.min(5, sanitizedOptions.retries));
|
|
191
195
|
}
|
|
192
196
|
mondayFetchOptions = {
|
|
193
|
-
...
|
|
197
|
+
...mondayFetchOptions,
|
|
194
198
|
...sanitizedOptions,
|
|
195
199
|
};
|
|
196
200
|
}
|
|
197
201
|
static getRequestFetchOptions() {
|
|
198
202
|
return mondayFetchOptions;
|
|
199
203
|
}
|
|
204
|
+
static resetRequestFetchOptions() {
|
|
205
|
+
mondayFetchOptions = {};
|
|
206
|
+
}
|
|
200
207
|
static setIgniteClient(client) {
|
|
201
208
|
igniteClient = client;
|
|
202
209
|
}
|
|
@@ -206,8 +213,8 @@ class AuthorizationInternalService {
|
|
|
206
213
|
if (!this.igniteClient) {
|
|
207
214
|
return defaultTimeout;
|
|
208
215
|
}
|
|
209
|
-
const overrideTimeouts = this.igniteClient.configuration.getObjectValue('override-outgoing-request-timeout-ms', {});
|
|
210
216
|
try {
|
|
217
|
+
const overrideTimeouts = this.igniteClient.configuration.getObjectValue('override-outgoing-request-timeout-ms', {});
|
|
211
218
|
if (process.env.APP_NAME && process.env.APP_NAME in overrideTimeouts) {
|
|
212
219
|
return overrideTimeouts[process.env.APP_NAME];
|
|
213
220
|
}
|
|
@@ -224,11 +231,17 @@ class AuthorizationInternalService {
|
|
|
224
231
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
225
232
|
const retryConfig = getRetryConfig();
|
|
226
233
|
const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
|
|
227
|
-
const defaultRetryOn = (_attempt,
|
|
234
|
+
const defaultRetryOn = (_attempt, error, response, isTimeoutError) => {
|
|
235
|
+
if (isTimeoutError) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
const status = response?.status ?? error?.status;
|
|
239
|
+
return typeof status === 'number' ? statusMatchers.some(matcher => matcher(status)) : false;
|
|
240
|
+
};
|
|
228
241
|
// Sanitize retries from fetchOptions: clamp between 0 and 5
|
|
229
242
|
const rawMaxRetries = fetchOptions?.retries ?? retryConfig.retries;
|
|
230
243
|
const effectiveMaxRetries = Math.max(0, Math.min(5, rawMaxRetries));
|
|
231
|
-
const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
|
|
244
|
+
const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount }) + AuthorizationInternalService.getRequestTimeout();
|
|
232
245
|
return {
|
|
233
246
|
useRetries: fetchOptions?.useRetries ?? true,
|
|
234
247
|
maxRetries: effectiveMaxRetries,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
2
2
|
import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
|
|
3
3
|
import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
|
|
4
|
-
import
|
|
4
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
5
5
|
export interface AuthorizeResponse {
|
|
6
6
|
isAuthorized: boolean;
|
|
7
7
|
unauthorizedIds?: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../src/authorization-service.ts"],"names":[],"mappings":"AAGA,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;AAM1C,OAAO,
|
|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qBAAqB,EAAE,gBAAgB,CAAC,aAAa,
|
|
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,oBAAY,eAAe;IACzB,UAAU,mCAAmC;CAC9C;AAED,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAKjE,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -11,11 +11,6 @@ const ERROR_MESSAGES = {
|
|
|
11
11
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
12
12
|
};
|
|
13
13
|
const DEFAULT_FETCH_OPTIONS = {
|
|
14
|
-
retryPolicy: {
|
|
15
|
-
useRetries: true,
|
|
16
|
-
maxRetries: 3,
|
|
17
|
-
retryDelayMS: 10,
|
|
18
|
-
},
|
|
19
14
|
logPolicy: {
|
|
20
15
|
logErrors: 'error',
|
|
21
16
|
logRequests: 'info',
|
|
@@ -5,6 +5,9 @@ import type { AuthorizationFetchOptions } from './types/fetch-options';
|
|
|
5
5
|
export declare const MAX_RETRIES = 3;
|
|
6
6
|
export declare const RETRY_DELAY_MS = 20;
|
|
7
7
|
export declare const logger: import("bunyan");
|
|
8
|
+
/**
|
|
9
|
+
* Key used to retrieve retry configuration from Ignite.
|
|
10
|
+
*/
|
|
8
11
|
export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
|
|
9
12
|
export declare const onRetryCallback: OnRetryCallback;
|
|
10
13
|
/**
|
|
@@ -26,6 +29,7 @@ export declare class AuthorizationInternalService {
|
|
|
26
29
|
static generateInternalAuthToken(accountId: number, userId: number): string;
|
|
27
30
|
static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
|
|
28
31
|
static getRequestFetchOptions(): AuthorizationFetchOptions;
|
|
32
|
+
static resetRequestFetchOptions(): void;
|
|
29
33
|
static setIgniteClient(client: IgniteClient): void;
|
|
30
34
|
static getRequestTimeout(): number;
|
|
31
35
|
static getRetriesPolicy(): RetryPolicy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../../src/authorization-internal-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,WAAW,EAEZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAE/C,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../../src/authorization-internal-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,WAAW,EAEZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,MAAM,kBAA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
|
+
* Key used to retrieve retry configuration from Ignite.
|
|
10
|
+
*/
|
|
8
11
|
const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
|
|
9
12
|
let igniteClient;
|
|
10
13
|
const defaultRetryConfig = {
|
|
@@ -19,11 +22,17 @@ const defaultRetryConfig = {
|
|
|
19
22
|
* Sanitizes retry configuration values to ensure they are within valid ranges
|
|
20
23
|
*/
|
|
21
24
|
function sanitizeRetryConfig(config) {
|
|
25
|
+
const merged = { ...defaultRetryConfig, ...config };
|
|
22
26
|
return {
|
|
23
|
-
...
|
|
24
|
-
retries: Math.max(0, Math.min(5,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
...merged,
|
|
28
|
+
retries: Math.max(0, Math.min(5, merged.retries)),
|
|
29
|
+
baseDelayMs: Math.max(0, merged.baseDelayMs),
|
|
30
|
+
exponentBase: Math.max(1, Math.min(100, merged.exponentBase)),
|
|
31
|
+
jitterMinMs: Math.max(0, merged.jitterMinMs),
|
|
32
|
+
jitterMaxMs: Math.max(0, merged.jitterMaxMs),
|
|
33
|
+
retryOnStatusPatterns: Array.isArray(merged.retryOnStatusPatterns)
|
|
34
|
+
? merged.retryOnStatusPatterns
|
|
35
|
+
: defaultRetryConfig.retryOnStatusPatterns,
|
|
27
36
|
};
|
|
28
37
|
}
|
|
29
38
|
function getRetryConfig() {
|
|
@@ -45,6 +54,10 @@ function randomIntInclusive(min, max) {
|
|
|
45
54
|
}
|
|
46
55
|
return Math.floor(min + Math.random() * (max - min + 1));
|
|
47
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Helper to build status matchers from config patterns.
|
|
59
|
+
* @param patterns Array of patterns like "429", "5**", "5*9"
|
|
60
|
+
*/
|
|
48
61
|
function buildHttpStatusMatchers(patterns) {
|
|
49
62
|
const matchers = [];
|
|
50
63
|
const addWildcardMatcher = (wildcard) => {
|
|
@@ -97,13 +110,6 @@ function buildHttpStatusMatchers(patterns) {
|
|
|
97
110
|
}
|
|
98
111
|
return matchers;
|
|
99
112
|
}
|
|
100
|
-
function shouldRetryOnResponseStatus(responseOrStatus, statusMatchers) {
|
|
101
|
-
const status = responseOrStatus?.status;
|
|
102
|
-
if (typeof status !== 'number') {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
return statusMatchers.some(matcher => matcher(status));
|
|
106
|
-
}
|
|
107
113
|
const onRetryCallback = (attempt, error, response, isTimeoutError) => {
|
|
108
114
|
const effectiveMaxRetries = getRetryConfig().retries;
|
|
109
115
|
if (attempt == effectiveMaxRetries) {
|
|
@@ -126,9 +132,7 @@ const calcDelayDurationInMs = ({ attemptCount }) => {
|
|
|
126
132
|
const jitter = randomIntInclusive(jitterMin, jitterMax);
|
|
127
133
|
return expDelay + jitter;
|
|
128
134
|
};
|
|
129
|
-
let mondayFetchOptions = {
|
|
130
|
-
retries: defaultRetryConfig.retries,
|
|
131
|
-
};
|
|
135
|
+
let mondayFetchOptions = {};
|
|
132
136
|
class AuthorizationInternalService {
|
|
133
137
|
static get igniteClient() {
|
|
134
138
|
return igniteClient;
|
|
@@ -144,7 +148,7 @@ class AuthorizationInternalService {
|
|
|
144
148
|
}
|
|
145
149
|
static failIfNotCoveredByAuthorization(request) {
|
|
146
150
|
if (!request.authorizationCheckPerformed && !request.authorizationSkipPerformed) {
|
|
147
|
-
throw 'Endpoint is not covered by authorization check';
|
|
151
|
+
throw new Error('Endpoint is not covered by authorization check');
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
static throwOnHttpErrorIfNeeded(response, placement) {
|
|
@@ -168,13 +172,16 @@ class AuthorizationInternalService {
|
|
|
168
172
|
sanitizedOptions.retries = Math.max(0, Math.min(5, sanitizedOptions.retries));
|
|
169
173
|
}
|
|
170
174
|
mondayFetchOptions = {
|
|
171
|
-
...
|
|
175
|
+
...mondayFetchOptions,
|
|
172
176
|
...sanitizedOptions,
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
179
|
static getRequestFetchOptions() {
|
|
176
180
|
return mondayFetchOptions;
|
|
177
181
|
}
|
|
182
|
+
static resetRequestFetchOptions() {
|
|
183
|
+
mondayFetchOptions = {};
|
|
184
|
+
}
|
|
178
185
|
static setIgniteClient(client) {
|
|
179
186
|
igniteClient = client;
|
|
180
187
|
}
|
|
@@ -184,8 +191,8 @@ class AuthorizationInternalService {
|
|
|
184
191
|
if (!this.igniteClient) {
|
|
185
192
|
return defaultTimeout;
|
|
186
193
|
}
|
|
187
|
-
const overrideTimeouts = this.igniteClient.configuration.getObjectValue('override-outgoing-request-timeout-ms', {});
|
|
188
194
|
try {
|
|
195
|
+
const overrideTimeouts = this.igniteClient.configuration.getObjectValue('override-outgoing-request-timeout-ms', {});
|
|
189
196
|
if (process.env.APP_NAME && process.env.APP_NAME in overrideTimeouts) {
|
|
190
197
|
return overrideTimeouts[process.env.APP_NAME];
|
|
191
198
|
}
|
|
@@ -202,11 +209,17 @@ class AuthorizationInternalService {
|
|
|
202
209
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
203
210
|
const retryConfig = getRetryConfig();
|
|
204
211
|
const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
|
|
205
|
-
const defaultRetryOn = (_attempt,
|
|
212
|
+
const defaultRetryOn = (_attempt, error, response, isTimeoutError) => {
|
|
213
|
+
if (isTimeoutError) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
const status = response?.status ?? error?.status;
|
|
217
|
+
return typeof status === 'number' ? statusMatchers.some(matcher => matcher(status)) : false;
|
|
218
|
+
};
|
|
206
219
|
// Sanitize retries from fetchOptions: clamp between 0 and 5
|
|
207
220
|
const rawMaxRetries = fetchOptions?.retries ?? retryConfig.retries;
|
|
208
221
|
const effectiveMaxRetries = Math.max(0, Math.min(5, rawMaxRetries));
|
|
209
|
-
const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
|
|
222
|
+
const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount }) + AuthorizationInternalService.getRequestTimeout();
|
|
210
223
|
return {
|
|
211
224
|
useRetries: fetchOptions?.useRetries ?? true,
|
|
212
225
|
maxRetries: effectiveMaxRetries,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
2
2
|
import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
|
|
3
3
|
import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
|
|
4
|
-
import
|
|
4
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
5
5
|
export interface AuthorizeResponse {
|
|
6
6
|
isAuthorized: boolean;
|
|
7
7
|
unauthorizedIds?: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AAGA,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;AAM1C,OAAO,
|
|
1
|
+
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AAGA,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;AAM1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAOlE,MAAM,WAAW,i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AC,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,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
|
|
@@ -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;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,oBAAY,eAAe;IACzB,UAAU,mCAAmC;CAC9C;AAED,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,
|
|
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,oBAAY,eAAe;IACzB,UAAU,mCAAmC;CAC9C;AAED,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAKjE,CAAC"}
|
package/dist/esm/constants.mjs
CHANGED
|
@@ -9,11 +9,6 @@ const ERROR_MESSAGES = {
|
|
|
9
9
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
10
10
|
};
|
|
11
11
|
const DEFAULT_FETCH_OPTIONS = {
|
|
12
|
-
retryPolicy: {
|
|
13
|
-
useRetries: true,
|
|
14
|
-
maxRetries: 3,
|
|
15
|
-
retryDelayMS: 10,
|
|
16
|
-
},
|
|
17
12
|
logPolicy: {
|
|
18
13
|
logErrors: 'error',
|
|
19
14
|
logRequests: 'info',
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetricsClient } from './metrics-service';
|
|
2
2
|
import * as TestKit from './testKit';
|
|
3
|
-
import
|
|
3
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
4
4
|
interface MetricsInitOptions {
|
|
5
5
|
client?: MetricsClient;
|
|
6
6
|
serviceName?: string;
|
|
@@ -31,5 +31,4 @@ export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest,
|
|
|
31
31
|
export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
|
|
32
32
|
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
33
33
|
export { TestKit };
|
|
34
|
-
export type { AuthorizationFetchOptions };
|
|
35
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,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,yBAAyB,CAAC;IAC/C,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,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/memberships.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { handleApiError } from './utils/api-error-handler.mjs';
|
|
3
3
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
4
|
-
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
5
4
|
import { AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
5
|
+
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
6
6
|
|
|
7
7
|
class MembershipsService {
|
|
8
8
|
static API_PATHS = {
|
|
@@ -60,8 +60,8 @@ class MembershipsService {
|
|
|
60
60
|
body: JSON.stringify({ memberships }),
|
|
61
61
|
}, {
|
|
62
62
|
...this.fetchOptions,
|
|
63
|
-
timeout:
|
|
64
|
-
retryPolicy:
|
|
63
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
64
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
@@ -93,8 +93,8 @@ class MembershipsService {
|
|
|
93
93
|
body: JSON.stringify({ memberships }),
|
|
94
94
|
}, {
|
|
95
95
|
...this.fetchOptions,
|
|
96
|
-
timeout:
|
|
97
|
-
retryPolicy:
|
|
96
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
97
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
catch (err) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
3
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
4
|
-
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
5
4
|
import { AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
5
|
+
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
6
6
|
|
|
7
7
|
const API_PATH = '/roles/account/{accountId}';
|
|
8
8
|
class RolesService {
|
|
@@ -13,10 +13,7 @@ export interface AccountProductScope {
|
|
|
13
13
|
export interface AccountScope {
|
|
14
14
|
accountId: number;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
credentialsSharedConfigId: number;
|
|
18
|
-
}
|
|
19
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope | CredentialsSharedConfigScope;
|
|
16
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
20
17
|
export interface Translation {
|
|
21
18
|
key: string;
|
|
22
19
|
[option: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEzG,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB;;;;;OAKG;IACH,cAAc,IAAI;IAClB,SAAS,IAAI;IACb,WAAW,IAAI;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAkB3G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAEtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEzE"}
|
|
@@ -21,9 +21,6 @@ function scopeToResource(scope) {
|
|
|
21
21
|
if ('accountId' in scope) {
|
|
22
22
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
23
23
|
}
|
|
24
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
25
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
26
|
-
}
|
|
27
24
|
throw new Error('Unsupported scope provided');
|
|
28
25
|
}
|
|
29
26
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetricsClient } from './metrics-service';
|
|
2
2
|
import * as TestKit from './testKit';
|
|
3
|
-
import
|
|
3
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
4
4
|
interface MetricsInitOptions {
|
|
5
5
|
client?: MetricsClient;
|
|
6
6
|
serviceName?: string;
|
|
@@ -31,5 +31,4 @@ export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest,
|
|
|
31
31
|
export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
|
|
32
32
|
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
33
33
|
export { TestKit };
|
|
34
|
-
export type { AuthorizationFetchOptions };
|
|
35
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aA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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/memberships.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
|
|
4
4
|
const utils_apiErrorHandler = require('./utils/api-error-handler.js');
|
|
5
5
|
const attributionsService = require('./attributions-service.js');
|
|
6
|
-
const constants = require('./constants.js');
|
|
7
6
|
const authorizationInternalService = require('./authorization-internal-service.js');
|
|
7
|
+
const constants = require('./constants.js');
|
|
8
8
|
|
|
9
9
|
class MembershipsService {
|
|
10
10
|
static API_PATHS = {
|
|
@@ -62,8 +62,8 @@ class MembershipsService {
|
|
|
62
62
|
body: JSON.stringify({ memberships }),
|
|
63
63
|
}, {
|
|
64
64
|
...this.fetchOptions,
|
|
65
|
-
timeout:
|
|
66
|
-
retryPolicy:
|
|
65
|
+
timeout: authorizationInternalService.AuthorizationInternalService.getRequestTimeout(),
|
|
66
|
+
retryPolicy: authorizationInternalService.AuthorizationInternalService.getRetriesPolicy(),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
catch (err) {
|
|
@@ -95,8 +95,8 @@ class MembershipsService {
|
|
|
95
95
|
body: JSON.stringify({ memberships }),
|
|
96
96
|
}, {
|
|
97
97
|
...this.fetchOptions,
|
|
98
|
-
timeout:
|
|
99
|
-
retryPolicy:
|
|
98
|
+
timeout: authorizationInternalService.AuthorizationInternalService.getRequestTimeout(),
|
|
99
|
+
retryPolicy: authorizationInternalService.AuthorizationInternalService.getRetriesPolicy(),
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
catch (err) {
|
package/dist/roles-service.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
|
|
4
4
|
const mondayFetchApi = require('@mondaydotcomorg/monday-fetch-api');
|
|
5
5
|
const attributionsService = require('./attributions-service.js');
|
|
6
|
-
const constants = require('./constants.js');
|
|
7
6
|
const authorizationInternalService = require('./authorization-internal-service.js');
|
|
7
|
+
const constants = require('./constants.js');
|
|
8
8
|
|
|
9
9
|
const API_PATH = '/roles/account/{accountId}';
|
|
10
10
|
class RolesService {
|
|
@@ -13,10 +13,7 @@ export interface AccountProductScope {
|
|
|
13
13
|
export interface AccountScope {
|
|
14
14
|
accountId: number;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
credentialsSharedConfigId: number;
|
|
18
|
-
}
|
|
19
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope | CredentialsSharedConfigScope;
|
|
16
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
20
17
|
export interface Translation {
|
|
21
18
|
key: string;
|
|
22
19
|
[option: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEzG,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB;;;;;OAKG;IACH,cAAc,IAAI;IAClB,SAAS,IAAI;IACb,WAAW,IAAI;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAG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AG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAkB3G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAEtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEzE"}
|
|
@@ -29,9 +29,6 @@ function scopeToResource(scope) {
|
|
|
29
29
|
if ('accountId' in scope) {
|
|
30
30
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
31
31
|
}
|
|
32
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
33
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
34
|
-
}
|
|
35
32
|
throw new Error('Unsupported scope provided');
|
|
36
33
|
}
|
|
37
34
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4-feat-shaime-fix-timeout-53ee888",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mondaydotcomorg/ignite-sdk": "^2.2.7",
|
|
24
|
-
"@mondaydotcomorg/monday-fetch": "^
|
|
24
|
+
"@mondaydotcomorg/monday-fetch": "^0.0.7",
|
|
25
25
|
"@mondaydotcomorg/monday-fetch-api": "^1.0.2",
|
|
26
26
|
"@mondaydotcomorg/monday-jwt": "^3.0.14",
|
|
27
27
|
"@mondaydotcomorg/monday-logger": "^4.0.11",
|
|
@@ -16,6 +16,9 @@ export const MAX_RETRIES = 3;
|
|
|
16
16
|
export const RETRY_DELAY_MS = 20;
|
|
17
17
|
export const logger = MondayLogger.getLogger();
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Key used to retrieve retry configuration from Ignite.
|
|
21
|
+
*/
|
|
19
22
|
export const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
|
|
20
23
|
|
|
21
24
|
let igniteClient: IgniteClient | undefined;
|
|
@@ -48,12 +51,18 @@ const defaultRetryConfig: RetryConfig = {
|
|
|
48
51
|
/**
|
|
49
52
|
* Sanitizes retry configuration values to ensure they are within valid ranges
|
|
50
53
|
*/
|
|
51
|
-
function sanitizeRetryConfig(config: RetryConfig): RetryConfig {
|
|
54
|
+
function sanitizeRetryConfig(config: Partial<RetryConfig>): RetryConfig {
|
|
55
|
+
const merged = { ...defaultRetryConfig, ...config };
|
|
52
56
|
return {
|
|
53
|
-
...
|
|
54
|
-
retries: Math.max(0, Math.min(5,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
...merged,
|
|
58
|
+
retries: Math.max(0, Math.min(5, merged.retries)),
|
|
59
|
+
baseDelayMs: Math.max(0, merged.baseDelayMs),
|
|
60
|
+
exponentBase: Math.max(1, Math.min(100, merged.exponentBase)),
|
|
61
|
+
jitterMinMs: Math.max(0, merged.jitterMinMs),
|
|
62
|
+
jitterMaxMs: Math.max(0, merged.jitterMaxMs),
|
|
63
|
+
retryOnStatusPatterns: Array.isArray(merged.retryOnStatusPatterns)
|
|
64
|
+
? merged.retryOnStatusPatterns
|
|
65
|
+
: defaultRetryConfig.retryOnStatusPatterns,
|
|
57
66
|
};
|
|
58
67
|
}
|
|
59
68
|
|
|
@@ -62,7 +71,10 @@ function getRetryConfig(): RetryConfig {
|
|
|
62
71
|
return defaultRetryConfig;
|
|
63
72
|
}
|
|
64
73
|
try {
|
|
65
|
-
const config = igniteClient.configuration.getObjectValue<RetryConfig
|
|
74
|
+
const config = igniteClient.configuration.getObjectValue<Partial<RetryConfig>>(
|
|
75
|
+
IGNITE_RETRY_CONFIG_KEY,
|
|
76
|
+
defaultRetryConfig
|
|
77
|
+
);
|
|
66
78
|
return sanitizeRetryConfig(config);
|
|
67
79
|
} catch (error) {
|
|
68
80
|
logger.error(
|
|
@@ -82,6 +94,10 @@ function randomIntInclusive(min: number, max: number): number {
|
|
|
82
94
|
|
|
83
95
|
type StatusMatcher = (status: number) => boolean;
|
|
84
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Helper to build status matchers from config patterns.
|
|
99
|
+
* @param patterns Array of patterns like "429", "5**", "5*9"
|
|
100
|
+
*/
|
|
85
101
|
function buildHttpStatusMatchers(patterns: string[]): StatusMatcher[] {
|
|
86
102
|
const matchers: StatusMatcher[] = [];
|
|
87
103
|
|
|
@@ -145,6 +161,11 @@ function buildHttpStatusMatchers(patterns: string[]): StatusMatcher[] {
|
|
|
145
161
|
return matchers;
|
|
146
162
|
}
|
|
147
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Determines if a request should be retried based on the response status.
|
|
166
|
+
* @param responseOrStatus The response object or null/undefined
|
|
167
|
+
* @param statusMatchers Array of matchers to check against
|
|
168
|
+
*/
|
|
148
169
|
function shouldRetryOnResponseStatus(
|
|
149
170
|
responseOrStatus: Response | null | undefined,
|
|
150
171
|
statusMatchers: StatusMatcher[]
|
|
@@ -190,9 +211,7 @@ export const calcDelayDurationInMs = ({ attemptCount }: { attemptCount: number }
|
|
|
190
211
|
return expDelay + jitter;
|
|
191
212
|
};
|
|
192
213
|
|
|
193
|
-
let mondayFetchOptions: AuthorizationFetchOptions = {
|
|
194
|
-
retries: defaultRetryConfig.retries,
|
|
195
|
-
};
|
|
214
|
+
let mondayFetchOptions: AuthorizationFetchOptions = {};
|
|
196
215
|
|
|
197
216
|
export class AuthorizationInternalService {
|
|
198
217
|
static get igniteClient(): IgniteClient | undefined {
|
|
@@ -212,7 +231,7 @@ export class AuthorizationInternalService {
|
|
|
212
231
|
|
|
213
232
|
static failIfNotCoveredByAuthorization(request: BaseRequest): void {
|
|
214
233
|
if (!request.authorizationCheckPerformed && !request.authorizationSkipPerformed) {
|
|
215
|
-
throw 'Endpoint is not covered by authorization check';
|
|
234
|
+
throw new Error('Endpoint is not covered by authorization check');
|
|
216
235
|
}
|
|
217
236
|
}
|
|
218
237
|
|
|
@@ -248,7 +267,7 @@ export class AuthorizationInternalService {
|
|
|
248
267
|
sanitizedOptions.retries = Math.max(0, Math.min(5, sanitizedOptions.retries));
|
|
249
268
|
}
|
|
250
269
|
mondayFetchOptions = {
|
|
251
|
-
...
|
|
270
|
+
...mondayFetchOptions,
|
|
252
271
|
...sanitizedOptions,
|
|
253
272
|
};
|
|
254
273
|
}
|
|
@@ -257,6 +276,10 @@ export class AuthorizationInternalService {
|
|
|
257
276
|
return mondayFetchOptions;
|
|
258
277
|
}
|
|
259
278
|
|
|
279
|
+
static resetRequestFetchOptions() {
|
|
280
|
+
mondayFetchOptions = {};
|
|
281
|
+
}
|
|
282
|
+
|
|
260
283
|
static setIgniteClient(client: IgniteClient) {
|
|
261
284
|
igniteClient = client;
|
|
262
285
|
}
|
|
@@ -264,16 +287,15 @@ export class AuthorizationInternalService {
|
|
|
264
287
|
static getRequestTimeout() {
|
|
265
288
|
const isDevEnv = process.env.NODE_ENV === 'development';
|
|
266
289
|
const defaultTimeout = isDevEnv ? 60000 : 2000;
|
|
267
|
-
|
|
268
290
|
if (!this.igniteClient) {
|
|
269
291
|
return defaultTimeout;
|
|
270
292
|
}
|
|
271
293
|
|
|
272
|
-
const overrideTimeouts = this.igniteClient.configuration.getObjectValue<Record<string, number>>(
|
|
273
|
-
'override-outgoing-request-timeout-ms',
|
|
274
|
-
{}
|
|
275
|
-
);
|
|
276
294
|
try {
|
|
295
|
+
const overrideTimeouts = this.igniteClient.configuration.getObjectValue<Record<string, number>>(
|
|
296
|
+
'override-outgoing-request-timeout-ms',
|
|
297
|
+
{}
|
|
298
|
+
);
|
|
277
299
|
if (process.env.APP_NAME && process.env.APP_NAME in overrideTimeouts) {
|
|
278
300
|
return overrideTimeouts[process.env.APP_NAME];
|
|
279
301
|
} else {
|
|
@@ -292,12 +314,18 @@ export class AuthorizationInternalService {
|
|
|
292
314
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
293
315
|
const retryConfig = getRetryConfig();
|
|
294
316
|
const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
|
|
295
|
-
const defaultRetryOn = (_attempt,
|
|
296
|
-
|
|
317
|
+
const defaultRetryOn = (_attempt, error, response, isTimeoutError) => {
|
|
318
|
+
if (isTimeoutError) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
const status = response?.status ?? (error as any)?.status;
|
|
322
|
+
return typeof status === 'number' ? statusMatchers.some(matcher => matcher(status)) : false;
|
|
323
|
+
};
|
|
297
324
|
// Sanitize retries from fetchOptions: clamp between 0 and 5
|
|
298
325
|
const rawMaxRetries = fetchOptions?.retries ?? retryConfig.retries;
|
|
299
326
|
const effectiveMaxRetries = Math.max(0, Math.min(5, rawMaxRetries));
|
|
300
|
-
const defaultGetTimeout: GetTimeout = timeoutsCount =>
|
|
327
|
+
const defaultGetTimeout: GetTimeout = timeoutsCount =>
|
|
328
|
+
calcDelayDurationInMs({ attemptCount: timeoutsCount }) + AuthorizationInternalService.getRequestTimeout();
|
|
301
329
|
|
|
302
330
|
return {
|
|
303
331
|
useRetries: fetchOptions?.useRetries ?? true,
|
|
@@ -16,7 +16,7 @@ import { getAttributionsFromApi, getProfile } from './attributions-service';
|
|
|
16
16
|
import { GraphApi } from './clients/graph-api';
|
|
17
17
|
import { PlatformApi } from './clients/platform-api';
|
|
18
18
|
import { scopeToResource } from './utils/authorization.utils';
|
|
19
|
-
import
|
|
19
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
20
20
|
|
|
21
21
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
22
22
|
const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
package/src/constants.ts
CHANGED
|
@@ -15,11 +15,6 @@ export const ERROR_MESSAGES = {
|
|
|
15
15
|
} as const;
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_FETCH_OPTIONS: RecursivePartial<FetcherConfig> = {
|
|
18
|
-
retryPolicy: {
|
|
19
|
-
useRetries: true,
|
|
20
|
-
maxRetries: 3,
|
|
21
|
-
retryDelayMS: 10,
|
|
22
|
-
},
|
|
23
18
|
logPolicy: {
|
|
24
19
|
logErrors: 'error',
|
|
25
20
|
logRequests: 'info',
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { setPrometheus } from './prometheus-service';
|
|
|
2
2
|
import { setIgniteClient, setRedisClient, setRequestFetchOptions } from './authorization-service';
|
|
3
3
|
import { initializeMetrics, MetricsClient } from './metrics-service';
|
|
4
4
|
import * as TestKit from './testKit';
|
|
5
|
-
import
|
|
5
|
+
import { AuthorizationFetchOptions } from './types/fetch-options';
|
|
6
6
|
|
|
7
7
|
interface MetricsInitOptions {
|
|
8
8
|
client?: MetricsClient;
|
|
@@ -94,5 +94,3 @@ export {
|
|
|
94
94
|
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
95
95
|
|
|
96
96
|
export { TestKit };
|
|
97
|
-
|
|
98
|
-
export type { AuthorizationFetchOptions };
|
package/src/memberships.ts
CHANGED
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
} from 'types/memberships';
|
|
9
9
|
import { handleApiError } from 'utils/api-error-handler';
|
|
10
10
|
import { getAttributionsFromApi } from './attributions-service';
|
|
11
|
+
import { AuthorizationInternalService } from './authorization-internal-service';
|
|
11
12
|
|
|
12
13
|
import { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES } from './constants';
|
|
13
|
-
import { AuthorizationInternalService } from './authorization-internal-service';
|
|
14
14
|
|
|
15
15
|
export class MembershipsService {
|
|
16
16
|
private static API_PATHS = {
|
|
@@ -72,8 +72,8 @@ export class MembershipsService {
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
...this.fetchOptions,
|
|
75
|
-
timeout:
|
|
76
|
-
retryPolicy:
|
|
75
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
76
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
77
77
|
}
|
|
78
78
|
);
|
|
79
79
|
} catch (err) {
|
|
@@ -108,8 +108,8 @@ export class MembershipsService {
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
...this.fetchOptions,
|
|
111
|
-
timeout:
|
|
112
|
-
retryPolicy:
|
|
111
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
112
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
} catch (err) {
|
package/src/roles-service.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Api, FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend
|
|
|
2
2
|
import { HttpFetcherError, RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
3
|
import { RoleCreateRequest, RolesResponse, RoleUpdateRequest } from 'types/roles';
|
|
4
4
|
import { getAttributionsFromApi } from 'attributions-service';
|
|
5
|
-
import { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES } from './constants';
|
|
6
5
|
import { AuthorizationInternalService } from './authorization-internal-service';
|
|
6
|
+
import { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES } from './constants';
|
|
7
7
|
|
|
8
8
|
const API_PATH = '/roles/account/{accountId}';
|
|
9
9
|
|
|
@@ -18,17 +18,7 @@ export interface AccountScope {
|
|
|
18
18
|
accountId: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export
|
|
22
|
-
credentialsSharedConfigId: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type ScopeOptions =
|
|
26
|
-
| WorkspaceScope
|
|
27
|
-
| BoardScope
|
|
28
|
-
| PulseScope
|
|
29
|
-
| AccountProductScope
|
|
30
|
-
| AccountScope
|
|
31
|
-
| CredentialsSharedConfigScope;
|
|
21
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
32
22
|
|
|
33
23
|
export interface Translation {
|
|
34
24
|
key: string;
|
|
@@ -28,9 +28,6 @@ export function scopeToResource(scope: ScopeOptions): { resourceType: ResourceTy
|
|
|
28
28
|
if ('accountId' in scope) {
|
|
29
29
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
30
30
|
}
|
|
31
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
32
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
33
|
-
}
|
|
34
31
|
|
|
35
32
|
throw new Error('Unsupported scope provided');
|
|
36
33
|
}
|