Skip to content

Commit 23c4e9e

Browse files
gyaneshgouraw-oktasteaksdeveloperkunalleefreemanxyztusharpandey13
authored
Fix Typescript compilation for 4.6.3 (#896)
Duplicates PR #812 to run scans and resolve commit sign issue. --------- Signed-off-by: Frederik Prijck <frederik.prijck@auth0.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Steven Wexler <steven.m.wexler@gmail.com> Co-authored-by: KunalOfficial <35455566+developerkunal@users.noreply.github.com> Co-authored-by: Lee Freeman <lee@passionatepeople.io> Co-authored-by: Tushar Pandey <tushar.pandey@okta.com> Co-authored-by: Tushar Pandey <tusharpandey13@gmail.com> Co-authored-by: Frederik Prijck <frederik.prijck@auth0.com> Co-authored-by: Arpit Jain <167312832+arpit-jn@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kunal Dawar <kunal.dawar@okta.com> Co-authored-by: Subhankar Maiti <35273200+subhankarmaiti@users.noreply.github.com> Co-authored-by: martinml <217925+martinml@users.noreply.github.com> Co-authored-by: Rita Zerrizuela <zeta@widcket.com>
1 parent 81b2504 commit 23c4e9e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ const CODE_RE = /[?&]code=[^&]+/;
44
const STATE_RE = /[?&]state=[^&]+/;
55
const ERROR_RE = /[?&]error=[^&]+/;
66

7+
interface WithError {
8+
error: string;
9+
}
10+
11+
interface WithErrorAndDescription {
12+
error: string;
13+
error_description: string;
14+
}
15+
716
export const hasAuthParams = (searchParams = window.location.search): boolean =>
817
(CODE_RE.test(searchParams) || ERROR_RE.test(searchParams)) &&
918
STATE_RE.test(searchParams);
@@ -19,15 +28,17 @@ const normalizeErrorFn =
1928
error !== null &&
2029
typeof error === 'object' &&
2130
'error' in error &&
22-
typeof error.error === 'string'
31+
typeof (error as WithError).error === 'string'
2332
) {
2433
if (
2534
'error_description' in error &&
26-
typeof error.error_description === 'string'
35+
typeof (error as WithErrorAndDescription).error_description === 'string'
2736
) {
28-
return new OAuthError(error.error, error.error_description);
37+
const e = error as WithErrorAndDescription;
38+
return new OAuthError(e.error, e.error_description);
2939
}
30-
return new OAuthError(error.error);
40+
const e = error as WithError;
41+
return new OAuthError(e.error);
3142
}
3243
return new Error(fallbackMessage);
3344
};

0 commit comments

Comments
 (0)