Skip to content

Commit 6d8c45a

Browse files
committed
refactor: simplify authHandler type and standardize IterableAuthFailureReason enum values
1 parent c32447f commit 6d8c45a

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/core/classes/IterableConfig.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ export class IterableConfig {
204204
* @returns A promise that resolves to an `IterableAuthResponse`, a `string`,
205205
* or `undefined`.
206206
*/
207-
authHandler?: () => Promise<
208-
IterableAuthResponse | IterableAuthFailure | string | undefined
209-
>;
207+
authHandler?: () => Promise<IterableAuthResponse | string | undefined>;
210208

211209
/**
212210
* A callback function that is called when the SDK encounters an error while

src/core/enums/IterableAuthFailureReason.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ export enum IterableAuthFailureReason {
88
* An auth token's expiration must be less than one year from its issued-at
99
* time.
1010
*/
11-
AUTH_TOKEN_EXPIRATION_INVALID,
11+
AUTH_TOKEN_EXPIRATION_INVALID = 'AUTH_TOKEN_EXPIRATION_INVALID',
1212
/** The token has expired. */
13-
AUTH_TOKEN_EXPIRED,
13+
AUTH_TOKEN_EXPIRED = 'AUTH_TOKEN_EXPIRED',
1414
/** Token has an invalid format (failed a regular expression check). */
15-
AUTH_TOKEN_FORMAT_INVALID,
15+
AUTH_TOKEN_FORMAT_INVALID = 'AUTH_TOKEN_FORMAT_INVALID',
1616
/** `onAuthTokenRequested` threw an exception. */
17-
AUTH_TOKEN_GENERATION_ERROR,
17+
AUTH_TOKEN_GENERATION_ERROR = 'AUTH_TOKEN_GENERATION_ERROR',
1818
/** Any other error not captured by another constant. */
19-
AUTH_TOKEN_GENERIC_ERROR,
19+
AUTH_TOKEN_GENERIC_ERROR = 'AUTH_TOKEN_GENERIC_ERROR',
2020
/** Iterable has invalidated this token and it cannot be used. */
21-
AUTH_TOKEN_INVALIDATED,
21+
AUTH_TOKEN_INVALIDATED = 'AUTH_TOKEN_INVALIDATED',
2222
/** The request to Iterable's API did not include a JWT authorization header. */
23-
AUTH_TOKEN_MISSING,
23+
AUTH_TOKEN_MISSING = 'AUTH_TOKEN_MISSING',
2424
/** `onAuthTokenRequested` returned a null JWT token. */
25-
AUTH_TOKEN_NULL,
25+
AUTH_TOKEN_NULL = 'AUTH_TOKEN_NULL',
2626
/**
2727
* Iterable could not decode the token's payload (`iat`, `exp`, `email`,
2828
* or `userId`).
2929
*/
30-
AUTH_TOKEN_PAYLOAD_INVALID,
30+
AUTH_TOKEN_PAYLOAD_INVALID = 'AUTH_TOKEN_PAYLOAD_INVALID',
3131
/** Iterable could not validate the token's authenticity. */
32-
AUTH_TOKEN_SIGNATURE_INVALID,
32+
AUTH_TOKEN_SIGNATURE_INVALID = 'AUTH_TOKEN_SIGNATURE_INVALID',
3333
/**
3434
* The token doesn't include an `email` or a `userId`. Or, one of these
3535
* values is included, but it references a user that isn't in the Iterable
3636
* project.
3737
*/
38-
AUTH_TOKEN_USER_KEY_INVALID,
38+
AUTH_TOKEN_USER_KEY_INVALID = 'AUTH_TOKEN_USER_KEY_INVALID',
3939
}

0 commit comments

Comments
 (0)