Skip to content

Commit 762f333

Browse files
committed
feat: enhance IterableConfig with JWT error handling and retry policy support
1 parent af0065e commit 762f333

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

src/core/classes/IterableConfig.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { type IterableInAppMessage } from '../../inApp/classes/IterableInAppMessage';
2-
import { IterableInAppShowResponse } from '../../inApp/enums';
3-
import {
4-
IterableDataRegion,
5-
IterableLogLevel,
6-
IterablePushPlatform,
7-
} from '../enums';
2+
import { IterableInAppShowResponse } from '../../inApp/enums/IterableInAppShowResponse';
3+
import { IterableDataRegion } from '../enums/IterableDataRegion';
4+
import { IterableLogLevel } from '../enums/IterableLogLevel';
5+
import { IterablePushPlatform } from '../enums/IterablePushPlatform';
6+
import type { IterableAuthFailure } from '../types/IterableAuthFailure';
7+
import type { IterableRetryPolicy } from '../types/IterableRetryPolicy';
88
import { IterableAction } from './IterableAction';
99
import type { IterableActionContext } from './IterableActionContext';
1010
import type { IterableAuthResponse } from './IterableAuthResponse';
@@ -204,7 +204,27 @@ export class IterableConfig {
204204
* @returns A promise that resolves to an `IterableAuthResponse`, a `string`,
205205
* or `undefined`.
206206
*/
207-
authHandler?: () => Promise<IterableAuthResponse | string | undefined>;
207+
authHandler?: () => Promise<
208+
IterableAuthResponse | IterableAuthFailure | string | undefined
209+
>;
210+
211+
/**
212+
* A callback function which is called when an error occurs while validating a JWT.
213+
*
214+
* The retry for JWT should be automatically handled by the native SDK, so
215+
* this is just for logging/transparency purposes.
216+
*
217+
* @param authFailure - The details of the auth failure.
218+
*
219+
* @example
220+
* ```typescript
221+
* const config = new IterableConfig();
222+
* config.onJWTError = (authFailure) => {
223+
* console.error('Error fetching JWT:', authFailure);
224+
* };
225+
* ```
226+
*/
227+
onJWTError?: (authFailure: IterableAuthFailure) => void;
208228

209229
/**
210230
* Set the verbosity of Android and iOS project's log system.
@@ -213,6 +233,11 @@ export class IterableConfig {
213233
*/
214234
logLevel: IterableLogLevel = IterableLogLevel.info;
215235

236+
/**
237+
* The retry policy to use when retrying a request.
238+
*/
239+
retryPolicy?: IterableRetryPolicy;
240+
216241
/**
217242
* Set whether the React Native SDK should print function calls to console.
218243
*

0 commit comments

Comments
 (0)