@mondaydotcomorg/monday-authorization 3.9.2 → 3.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +2 -62
  2. package/dist/authorization-internal-service.d.ts +6 -18
  3. package/dist/authorization-internal-service.d.ts.map +1 -1
  4. package/dist/authorization-internal-service.js +23 -149
  5. package/dist/authorization-service.d.ts +2 -2
  6. package/dist/authorization-service.d.ts.map +1 -1
  7. package/dist/esm/authorization-internal-service.d.ts +6 -18
  8. package/dist/esm/authorization-internal-service.d.ts.map +1 -1
  9. package/dist/esm/authorization-internal-service.mjs +24 -146
  10. package/dist/esm/authorization-service.d.ts +2 -2
  11. package/dist/esm/authorization-service.d.ts.map +1 -1
  12. package/dist/esm/index.d.ts +2 -3
  13. package/dist/esm/index.d.ts.map +1 -1
  14. package/dist/esm/memberships.d.ts.map +1 -1
  15. package/dist/esm/memberships.mjs +2 -11
  16. package/dist/esm/roles-service.d.ts.map +1 -1
  17. package/dist/esm/roles-service.mjs +1 -6
  18. package/dist/esm/types/scoped-actions-contracts.d.ts +1 -4
  19. package/dist/esm/types/scoped-actions-contracts.d.ts.map +1 -1
  20. package/dist/esm/utils/assignment-schema.d.ts +7 -7
  21. package/dist/esm/utils/authorization.utils.d.ts.map +1 -1
  22. package/dist/esm/utils/authorization.utils.mjs +0 -3
  23. package/dist/index.d.ts +2 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/memberships.d.ts.map +1 -1
  26. package/dist/memberships.js +2 -11
  27. package/dist/roles-service.d.ts.map +1 -1
  28. package/dist/roles-service.js +1 -6
  29. package/dist/types/scoped-actions-contracts.d.ts +1 -4
  30. package/dist/types/scoped-actions-contracts.d.ts.map +1 -1
  31. package/dist/utils/assignment-schema.d.ts +7 -7
  32. package/dist/utils/authorization.utils.d.ts.map +1 -1
  33. package/dist/utils/authorization.utils.js +0 -3
  34. package/package.json +2 -2
  35. package/src/authorization-internal-service.ts +29 -212
  36. package/src/authorization-service.ts +2 -2
  37. package/src/index.ts +2 -4
  38. package/src/memberships.ts +2 -11
  39. package/src/roles-service.ts +1 -6
  40. package/src/types/scoped-actions-contracts.ts +1 -11
  41. 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 and retry configuration for testing:
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.
@@ -1,31 +1,19 @@
1
- import { OnRetryCallback, Response, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
1
+ import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
+ import { OnRetryCallback, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
2
3
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
4
  import { BaseRequest } from './types/general';
4
- import type { AuthorizationFetchOptions } from './types/fetch-options';
5
- export declare const MAX_RETRIES = 3;
6
- export declare const RETRY_DELAY_MS = 20;
7
5
  export declare const logger: import("bunyan");
8
- export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
9
6
  export declare const onRetryCallback: OnRetryCallback;
10
- /**
11
- * Exponential backoff retry delay callback
12
- * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
13
- * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
14
- */
15
- export declare const calcDelayDurationInMs: ({ attemptCount }: {
16
- attemptCount: number;
17
- }) => number;
18
7
  export declare class AuthorizationInternalService {
19
- static get igniteClient(): IgniteClient | undefined;
20
- static set igniteClient(client: IgniteClient | undefined);
8
+ static igniteClient?: IgniteClient;
21
9
  static skipAuthorization(requset: BaseRequest): void;
22
10
  static markAuthorized(request: BaseRequest): void;
23
11
  static failIfNotCoveredByAuthorization(request: BaseRequest): void;
24
- static throwOnHttpErrorIfNeeded(response: Response, placement: string): void;
12
+ static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
25
13
  static throwOnHttpError(status: number, placement: string): never;
26
14
  static generateInternalAuthToken(accountId: number, userId: number): string;
27
- static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
28
- static getRequestFetchOptions(): AuthorizationFetchOptions;
15
+ static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
16
+ static getRequestFetchOptions(): MondayFetchOptions;
29
17
  static setIgniteClient(client: IgniteClient): void;
30
18
  static getRequestTimeout(): number;
31
19
  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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,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;AAYF,qBAAa,4BAA4B;IACvC,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACnC,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIpD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIjD,MAAM,CAAC,+BAA+B,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAMlE,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,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"}
@@ -25,139 +25,31 @@ const MondayLogger__namespace = /*#__PURE__*/_interopNamespace(MondayLogger);
25
25
 
26
26
  const INTERNAL_APP_NAME = 'internal_ms';
27
27
  const MAX_RETRIES = 3;
28
- const RETRY_DELAY_MS = 20;
28
+ const RETRY_DELAY_MS = 10;
29
29
  const logger = MondayLogger__namespace.getLogger();
30
- const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
31
- let igniteClient;
32
- const defaultRetryConfig = {
30
+ const defaultMondayFetchOptions = {
33
31
  retries: MAX_RETRIES,
34
- baseDelayMs: RETRY_DELAY_MS,
35
- exponentBase: 2,
36
- jitterMinMs: 0,
37
- jitterMaxMs: 1000,
38
- retryOnStatusPatterns: ['429', '5**'],
32
+ callback: logOnFetchFail,
39
33
  };
40
- /**
41
- * Sanitizes retry configuration values to ensure they are within valid ranges
42
- */
43
- function sanitizeRetryConfig(config) {
44
- return {
45
- ...config,
46
- retries: Math.max(0, Math.min(5, config.retries)),
47
- exponentBase: Math.max(1, Math.min(100, config.exponentBase)),
48
- jitterMinMs: Math.max(0, config.jitterMinMs),
49
- };
50
- }
51
- function getRetryConfig() {
52
- if (!igniteClient) {
53
- return defaultRetryConfig;
54
- }
55
- try {
56
- const config = igniteClient.configuration.getObjectValue(IGNITE_RETRY_CONFIG_KEY, defaultRetryConfig);
57
- return sanitizeRetryConfig(config);
58
- }
59
- catch (error) {
60
- logger.error({ tag: 'authorization-service', error, key: IGNITE_RETRY_CONFIG_KEY, defaultValue: defaultRetryConfig }, 'Failed to get ignite retry config, using defaults');
61
- return defaultRetryConfig;
62
- }
63
- }
64
- function randomIntInclusive(min, max) {
65
- if (max <= min) {
66
- return min;
67
- }
68
- return Math.floor(min + Math.random() * (max - min + 1));
69
- }
70
- function buildHttpStatusMatchers(patterns) {
71
- const matchers = [];
72
- const addWildcardMatcher = (wildcard) => {
73
- // Normalized 3-char pattern with digits or '*'
74
- matchers.push((status) => {
75
- const s = String(status);
76
- if (s.length !== 3) {
77
- return false;
78
- }
79
- for (let i = 0; i < 3; i++) {
80
- const w = wildcard[i];
81
- const c = s[i];
82
- if (w === '*') {
83
- continue;
84
- }
85
- if (w !== c) {
86
- return false;
87
- }
88
- }
89
- return true;
90
- });
91
- };
92
- for (const raw of patterns ?? []) {
93
- const p = String(raw).trim();
94
- if (!p) {
95
- continue;
96
- }
97
- // Exact numeric status (e.g. "429")
98
- if (/^\d+$/.test(p)) {
99
- const exact = Number(p);
100
- if (Number.isFinite(exact)) {
101
- matchers.push((status) => status === exact);
102
- }
103
- continue;
104
- }
105
- // Wildcards for 3-digit HTTP codes:
106
- // - "5**" => 5xx
107
- // - "5*9" => 5?9
108
- if (/^[0-9*]+$/.test(p) && p.includes('*')) {
109
- const normalized = p.length < 3 ? p.padEnd(3, '*') : p;
110
- if (normalized.length !== 3) {
111
- logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status wildcard pattern (expected a 3-character pattern like "5**" or "5*9")');
112
- }
113
- else {
114
- addWildcardMatcher(normalized);
115
- }
116
- continue;
117
- }
118
- logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status pattern (supported: exact code like "429" or wildcard like "5**")');
119
- }
120
- return matchers;
121
- }
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
- const onRetryCallback = (attempt, error, response, isTimeoutError) => {
130
- const effectiveMaxRetries = getRetryConfig().retries;
131
- if (attempt == effectiveMaxRetries) {
132
- logger.error({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed');
34
+ const onRetryCallback = (attempt, error) => {
35
+ if (attempt == MAX_RETRIES) {
36
+ logger.error({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed');
133
37
  }
134
38
  else {
135
- logger.info({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed, trying again');
39
+ logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
136
40
  }
137
41
  };
138
- /**
139
- * Exponential backoff retry delay callback
140
- * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
141
- * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
142
- */
143
- const calcDelayDurationInMs = ({ attemptCount }) => {
144
- const { baseDelayMs, exponentBase, jitterMinMs, jitterMaxMs } = getRetryConfig();
145
- const jitterMin = Math.min(jitterMinMs, jitterMaxMs);
146
- const jitterMax = Math.max(jitterMinMs, jitterMaxMs);
147
- const expDelay = baseDelayMs * Math.pow(exponentBase, attemptCount - 1);
148
- const jitter = randomIntInclusive(jitterMin, jitterMax);
149
- return expDelay + jitter;
150
- };
151
- let mondayFetchOptions = {
152
- retries: defaultRetryConfig.retries,
153
- };
154
- class AuthorizationInternalService {
155
- static get igniteClient() {
156
- return igniteClient;
42
+ function logOnFetchFail(retriesLeft, error) {
43
+ if (retriesLeft == 0) {
44
+ logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
157
45
  }
158
- static set igniteClient(client) {
159
- igniteClient = client;
46
+ else {
47
+ logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
160
48
  }
49
+ }
50
+ let mondayFetchOptions = defaultMondayFetchOptions;
51
+ class AuthorizationInternalService {
52
+ static igniteClient;
161
53
  static skipAuthorization(requset) {
162
54
  requset.authorizationSkipPerformed = true;
163
55
  }
@@ -185,20 +77,16 @@ class AuthorizationInternalService {
185
77
  return mondayJwt.signAuthorizationHeader({ appName: INTERNAL_APP_NAME, accountId, userId });
186
78
  }
187
79
  static setRequestFetchOptions(customMondayFetchOptions) {
188
- const sanitizedOptions = { ...customMondayFetchOptions };
189
- if (sanitizedOptions.retries !== undefined) {
190
- sanitizedOptions.retries = Math.max(0, Math.min(5, sanitizedOptions.retries));
191
- }
192
80
  mondayFetchOptions = {
193
- ...defaultRetryConfig,
194
- ...sanitizedOptions,
81
+ ...defaultMondayFetchOptions,
82
+ ...customMondayFetchOptions,
195
83
  };
196
84
  }
197
85
  static getRequestFetchOptions() {
198
86
  return mondayFetchOptions;
199
87
  }
200
88
  static setIgniteClient(client) {
201
- igniteClient = client;
89
+ this.igniteClient = client;
202
90
  }
203
91
  static getRequestTimeout() {
204
92
  const isDevEnv = process.env.NODE_ENV === 'development';
@@ -222,29 +110,15 @@ class AuthorizationInternalService {
222
110
  }
223
111
  static getRetriesPolicy() {
224
112
  const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
225
- const retryConfig = getRetryConfig();
226
- const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
227
- const defaultRetryOn = (_attempt, _error, response, isTimeoutError) => isTimeoutError ? true : shouldRetryOnResponseStatus(response ?? undefined, statusMatchers);
228
- // Sanitize retries from fetchOptions: clamp between 0 and 5
229
- const rawMaxRetries = fetchOptions?.retries ?? retryConfig.retries;
230
- const effectiveMaxRetries = Math.max(0, Math.min(5, rawMaxRetries));
231
- const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
232
113
  return {
233
- useRetries: fetchOptions?.useRetries ?? true,
234
- maxRetries: effectiveMaxRetries,
235
- retryDelayMS: fetchOptions?.retryDelayMS ?? calcDelayDurationInMs,
236
- onRetry: fetchOptions?.callback ?? onRetryCallback,
237
- retryOn: fetchOptions?.retryOn ?? defaultRetryOn,
238
- timeoutRetries: fetchOptions?.timeoutRetries ?? effectiveMaxRetries,
239
- getTimeout: fetchOptions?.getTimeout ?? defaultGetTimeout,
114
+ useRetries: fetchOptions.retries !== undefined,
115
+ maxRetries: fetchOptions.retries !== undefined ? fetchOptions.retries : 0,
116
+ onRetry: onRetryCallback,
117
+ retryDelayMS: fetchOptions.retryDelay ?? RETRY_DELAY_MS,
240
118
  };
241
119
  }
242
120
  }
243
121
 
244
122
  exports.AuthorizationInternalService = AuthorizationInternalService;
245
- exports.IGNITE_RETRY_CONFIG_KEY = IGNITE_RETRY_CONFIG_KEY;
246
- exports.MAX_RETRIES = MAX_RETRIES;
247
- exports.RETRY_DELAY_MS = RETRY_DELAY_MS;
248
- exports.calcDelayDurationInMs = calcDelayDurationInMs;
249
123
  exports.logger = logger;
250
124
  exports.onRetryCallback = onRetryCallback;
@@ -1,13 +1,13 @@
1
+ import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
1
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
2
3
  import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
3
4
  import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
4
- import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export interface AuthorizeResponse {
6
6
  isAuthorized: boolean;
7
7
  unauthorizedIds?: number[];
8
8
  unauthorizedObjects?: AuthorizationObject[];
9
9
  }
10
- export declare function setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
10
+ export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
11
11
  export declare class AuthorizationService {
12
12
  private static get graphApi();
13
13
  private static _graphApi?;
@@ -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,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAOvE,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,yBAAyB,QAEzF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC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,MAAM,EAAE,MAAM,EACd,2BAA2B,EAAE,mBAAmB,EAAE,GACjD,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;OAGG;WACU,wBAAwB,CACnC,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,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
@@ -1,31 +1,19 @@
1
- import { OnRetryCallback, Response, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
1
+ import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
+ import { OnRetryCallback, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
2
3
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
4
  import { BaseRequest } from './types/general';
4
- import type { AuthorizationFetchOptions } from './types/fetch-options';
5
- export declare const MAX_RETRIES = 3;
6
- export declare const RETRY_DELAY_MS = 20;
7
5
  export declare const logger: import("bunyan");
8
- export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
9
6
  export declare const onRetryCallback: OnRetryCallback;
10
- /**
11
- * Exponential backoff retry delay callback
12
- * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
13
- * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
14
- */
15
- export declare const calcDelayDurationInMs: ({ attemptCount }: {
16
- attemptCount: number;
17
- }) => number;
18
7
  export declare class AuthorizationInternalService {
19
- static get igniteClient(): IgniteClient | undefined;
20
- static set igniteClient(client: IgniteClient | undefined);
8
+ static igniteClient?: IgniteClient;
21
9
  static skipAuthorization(requset: BaseRequest): void;
22
10
  static markAuthorized(request: BaseRequest): void;
23
11
  static failIfNotCoveredByAuthorization(request: BaseRequest): void;
24
- static throwOnHttpErrorIfNeeded(response: Response, placement: string): void;
12
+ static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
25
13
  static throwOnHttpError(status: number, placement: string): never;
26
14
  static generateInternalAuthToken(accountId: number, userId: number): string;
27
- static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
28
- static getRequestFetchOptions(): AuthorizationFetchOptions;
15
+ static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
16
+ static getRequestFetchOptions(): MondayFetchOptions;
29
17
  static setIgniteClient(client: IgniteClient): void;
30
18
  static getRequestTimeout(): number;
31
19
  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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RETRY_DELAY_MS = 10;
7
7
  const logger = MondayLogger.getLogger();
8
- const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
9
- let igniteClient;
10
- const defaultRetryConfig = {
8
+ const defaultMondayFetchOptions = {
11
9
  retries: MAX_RETRIES,
12
- baseDelayMs: RETRY_DELAY_MS,
13
- exponentBase: 2,
14
- jitterMinMs: 0,
15
- jitterMaxMs: 1000,
16
- retryOnStatusPatterns: ['429', '5**'],
10
+ callback: logOnFetchFail,
17
11
  };
18
- /**
19
- * Sanitizes retry configuration values to ensure they are within valid ranges
20
- */
21
- function sanitizeRetryConfig(config) {
22
- return {
23
- ...config,
24
- retries: Math.max(0, Math.min(5, config.retries)),
25
- exponentBase: Math.max(1, Math.min(100, config.exponentBase)),
26
- jitterMinMs: Math.max(0, config.jitterMinMs),
27
- };
28
- }
29
- function getRetryConfig() {
30
- if (!igniteClient) {
31
- return defaultRetryConfig;
32
- }
33
- try {
34
- const config = igniteClient.configuration.getObjectValue(IGNITE_RETRY_CONFIG_KEY, defaultRetryConfig);
35
- return sanitizeRetryConfig(config);
36
- }
37
- catch (error) {
38
- logger.error({ tag: 'authorization-service', error, key: IGNITE_RETRY_CONFIG_KEY, defaultValue: defaultRetryConfig }, 'Failed to get ignite retry config, using defaults');
39
- return defaultRetryConfig;
40
- }
41
- }
42
- function randomIntInclusive(min, max) {
43
- if (max <= min) {
44
- return min;
45
- }
46
- return Math.floor(min + Math.random() * (max - min + 1));
47
- }
48
- function buildHttpStatusMatchers(patterns) {
49
- const matchers = [];
50
- const addWildcardMatcher = (wildcard) => {
51
- // Normalized 3-char pattern with digits or '*'
52
- matchers.push((status) => {
53
- const s = String(status);
54
- if (s.length !== 3) {
55
- return false;
56
- }
57
- for (let i = 0; i < 3; i++) {
58
- const w = wildcard[i];
59
- const c = s[i];
60
- if (w === '*') {
61
- continue;
62
- }
63
- if (w !== c) {
64
- return false;
65
- }
66
- }
67
- return true;
68
- });
69
- };
70
- for (const raw of patterns ?? []) {
71
- const p = String(raw).trim();
72
- if (!p) {
73
- continue;
74
- }
75
- // Exact numeric status (e.g. "429")
76
- if (/^\d+$/.test(p)) {
77
- const exact = Number(p);
78
- if (Number.isFinite(exact)) {
79
- matchers.push((status) => status === exact);
80
- }
81
- continue;
82
- }
83
- // Wildcards for 3-digit HTTP codes:
84
- // - "5**" => 5xx
85
- // - "5*9" => 5?9
86
- if (/^[0-9*]+$/.test(p) && p.includes('*')) {
87
- const normalized = p.length < 3 ? p.padEnd(3, '*') : p;
88
- if (normalized.length !== 3) {
89
- logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status wildcard pattern (expected a 3-character pattern like "5**" or "5*9")');
90
- }
91
- else {
92
- addWildcardMatcher(normalized);
93
- }
94
- continue;
95
- }
96
- logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status pattern (supported: exact code like "429" or wildcard like "5**")');
97
- }
98
- return matchers;
99
- }
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
- const onRetryCallback = (attempt, error, response, isTimeoutError) => {
108
- const effectiveMaxRetries = getRetryConfig().retries;
109
- if (attempt == effectiveMaxRetries) {
110
- logger.error({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed');
12
+ const onRetryCallback = (attempt, error) => {
13
+ if (attempt == MAX_RETRIES) {
14
+ logger.error({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed');
111
15
  }
112
16
  else {
113
- logger.info({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed, trying again');
17
+ logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
114
18
  }
115
19
  };
116
- /**
117
- * Exponential backoff retry delay callback
118
- * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
119
- * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
120
- */
121
- const calcDelayDurationInMs = ({ attemptCount }) => {
122
- const { baseDelayMs, exponentBase, jitterMinMs, jitterMaxMs } = getRetryConfig();
123
- const jitterMin = Math.min(jitterMinMs, jitterMaxMs);
124
- const jitterMax = Math.max(jitterMinMs, jitterMaxMs);
125
- const expDelay = baseDelayMs * Math.pow(exponentBase, attemptCount - 1);
126
- const jitter = randomIntInclusive(jitterMin, jitterMax);
127
- return expDelay + jitter;
128
- };
129
- let mondayFetchOptions = {
130
- retries: defaultRetryConfig.retries,
131
- };
132
- class AuthorizationInternalService {
133
- static get igniteClient() {
134
- return igniteClient;
20
+ function logOnFetchFail(retriesLeft, error) {
21
+ if (retriesLeft == 0) {
22
+ logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
135
23
  }
136
- static set igniteClient(client) {
137
- igniteClient = client;
24
+ else {
25
+ logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
138
26
  }
27
+ }
28
+ let mondayFetchOptions = defaultMondayFetchOptions;
29
+ class AuthorizationInternalService {
30
+ static igniteClient;
139
31
  static skipAuthorization(requset) {
140
32
  requset.authorizationSkipPerformed = true;
141
33
  }
@@ -163,20 +55,16 @@ class AuthorizationInternalService {
163
55
  return signAuthorizationHeader({ appName: INTERNAL_APP_NAME, accountId, userId });
164
56
  }
165
57
  static setRequestFetchOptions(customMondayFetchOptions) {
166
- const sanitizedOptions = { ...customMondayFetchOptions };
167
- if (sanitizedOptions.retries !== undefined) {
168
- sanitizedOptions.retries = Math.max(0, Math.min(5, sanitizedOptions.retries));
169
- }
170
58
  mondayFetchOptions = {
171
- ...defaultRetryConfig,
172
- ...sanitizedOptions,
59
+ ...defaultMondayFetchOptions,
60
+ ...customMondayFetchOptions,
173
61
  };
174
62
  }
175
63
  static getRequestFetchOptions() {
176
64
  return mondayFetchOptions;
177
65
  }
178
66
  static setIgniteClient(client) {
179
- igniteClient = client;
67
+ this.igniteClient = client;
180
68
  }
181
69
  static getRequestTimeout() {
182
70
  const isDevEnv = process.env.NODE_ENV === 'development';
@@ -200,23 +88,13 @@ class AuthorizationInternalService {
200
88
  }
201
89
  static getRetriesPolicy() {
202
90
  const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
203
- const retryConfig = getRetryConfig();
204
- const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
205
- const defaultRetryOn = (_attempt, _error, response, isTimeoutError) => isTimeoutError ? true : shouldRetryOnResponseStatus(response ?? undefined, statusMatchers);
206
- // Sanitize retries from fetchOptions: clamp between 0 and 5
207
- const rawMaxRetries = fetchOptions?.retries ?? retryConfig.retries;
208
- const effectiveMaxRetries = Math.max(0, Math.min(5, rawMaxRetries));
209
- const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
210
91
  return {
211
- useRetries: fetchOptions?.useRetries ?? true,
212
- maxRetries: effectiveMaxRetries,
213
- retryDelayMS: fetchOptions?.retryDelayMS ?? calcDelayDurationInMs,
214
- onRetry: fetchOptions?.callback ?? onRetryCallback,
215
- retryOn: fetchOptions?.retryOn ?? defaultRetryOn,
216
- timeoutRetries: fetchOptions?.timeoutRetries ?? effectiveMaxRetries,
217
- getTimeout: fetchOptions?.getTimeout ?? defaultGetTimeout,
92
+ useRetries: fetchOptions.retries !== undefined,
93
+ maxRetries: fetchOptions.retries !== undefined ? fetchOptions.retries : 0,
94
+ onRetry: onRetryCallback,
95
+ retryDelayMS: fetchOptions.retryDelay ?? RETRY_DELAY_MS,
218
96
  };
219
97
  }
220
98
  }
221
99
 
222
- export { AuthorizationInternalService, IGNITE_RETRY_CONFIG_KEY, MAX_RETRIES, RETRY_DELAY_MS, calcDelayDurationInMs, logger, onRetryCallback };
100
+ export { AuthorizationInternalService, logger, onRetryCallback };
@@ -1,13 +1,13 @@
1
+ import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
1
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
2
3
  import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
3
4
  import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
4
- import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export interface AuthorizeResponse {
6
6
  isAuthorized: boolean;
7
7
  unauthorizedIds?: number[];
8
8
  unauthorizedObjects?: AuthorizationObject[];
9
9
  }
10
- export declare function setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
10
+ export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
11
11
  export declare class AuthorizationService {
12
12
  private static get graphApi();
13
13
  private static _graphApi?;
@@ -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,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAOvE,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,yBAAyB,QAEzF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC,MAAM,KAAK,WAAW,GAK7B;IACD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,C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