@auth0/auth0-react 2.0.1 → 2.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,6BAA4C,OAEzC,CAAC;AAgB9B,eAAO,MAAM,UAAU;WAXK,MAAM;;mCAC7B,KAUqD,CAAC;AAE3D,eAAO,MAAM,UAAU;WAbK,MAAM;;mCAC7B,KAYgE,CAAC;AAEtE;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,aAAc,GAAG,SAkBjD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,6BAA4C,OAEzC,CAAC;AA0B9B,eAAO,MAAM,UAAU,UAtBb,OAAO,KAAG,KAsBsC,CAAC;AAE3D,eAAO,MAAM,UAAU,UAxBb,OAAO,KAAG,KAwBiD,CAAC;AAEtE;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,aAAc,GAAG,SAkBjD,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Auth0",
3
3
  "name": "@auth0/auth0-react",
4
- "version": "2.0.1",
4
+ "version": "2.0.2",
5
5
  "description": "Auth0 SDK for React Single Page Applications (SPA)",
6
6
  "keywords": [
7
7
  "auth0",
@@ -67,7 +67,7 @@
67
67
  "eslint": "^8.28.0",
68
68
  "eslint-plugin-react": "^7.31.11",
69
69
  "eslint-plugin-react-hooks": "^4.6.0",
70
- "husky": "^4.3.8",
70
+ "husky": "^8.0.3",
71
71
  "jest": "^29.3.1",
72
72
  "jest-environment-jsdom": "^29.3.1",
73
73
  "jest-junit": "^15.0.0",
@@ -95,11 +95,6 @@
95
95
  "react": "^16.11.0 || ^17 || ^18",
96
96
  "react-dom": "^16.11.0 || ^17 || ^18"
97
97
  },
98
- "husky": {
99
- "hooks": {
100
- "pre-commit": "pretty-quick --staged"
101
- }
102
- },
103
98
  "dependencies": {
104
99
  "@auth0/auth0-spa-js": "^2.0.4"
105
100
  }
package/src/utils.tsx CHANGED
@@ -10,15 +10,25 @@ export const hasAuthParams = (searchParams = window.location.search): boolean =>
10
10
 
11
11
  const normalizeErrorFn =
12
12
  (fallbackMessage: string) =>
13
- (
14
- error: Error | { error: string; error_description?: string } | ProgressEvent
15
- ): Error => {
16
- if ('error' in error) {
17
- return new OAuthError(error.error, error.error_description);
18
- }
13
+ (error: unknown): Error => {
19
14
  if (error instanceof Error) {
20
15
  return error;
21
16
  }
17
+ // try to check errors of the following form: {error: string; error_description?: string}
18
+ if (
19
+ error !== null &&
20
+ typeof error === 'object' &&
21
+ 'error' in error &&
22
+ typeof error.error === 'string'
23
+ ) {
24
+ if (
25
+ 'error_description' in error &&
26
+ typeof error.error_description === 'string'
27
+ ) {
28
+ return new OAuthError(error.error, error.error_description);
29
+ }
30
+ return new OAuthError(error.error);
31
+ }
22
32
  return new Error(fallbackMessage);
23
33
  };
24
34