Skip to content

Commit

Permalink
#409 Implement timeout support to networking Client (#423)
Browse files Browse the repository at this point in the history
* Implement timeout support to networking Client

* Change test timeout to 2 seconds

Co-authored-by: Rita Zerrizuela <[email protected]>
  • Loading branch information
mnylen and Widcket authored Jan 12, 2022
1 parent 70fe69b commit 6a9d257
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 44 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Auth from './src/auth';
import Users from './src/management/users';
import WebAuth from './src/webauth';
export {TimeoutError} from './src/utils/fetchWithTimeout';

/**
* Auth0 for React Native client
Expand All @@ -9,7 +10,6 @@ import WebAuth from './src/webauth';
* @class Auth0
*/
export default class Auth0 {

/**
* Creates an instance of Auth0.
* @param {Object} options your Auth0 application information
Expand All @@ -19,7 +19,7 @@ export default class Auth0 {
* @memberof Auth0
*/
constructor(options = {}) {
const { domain, clientId, ...extras } = options;
const {domain, clientId, ...extras} = options;
this.auth = new Auth({baseUrl: domain, clientId, ...extras});
this.webAuth = new WebAuth(this.auth);
this.options = options;
Expand All @@ -31,7 +31,7 @@ export default class Auth0 {
* @return {Users}
*/
users(token) {
const { domain, clientId, ...extras } = this.options;
const {domain, clientId, ...extras} = this.options;
return new Users({baseUrl: domain, clientId, ...extras, token});
}
};
}
21 changes: 21 additions & 0 deletions src/auth/__tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -163,6 +164,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -178,6 +180,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -207,6 +210,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -237,6 +241,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -252,6 +257,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -267,6 +273,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -302,6 +309,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -317,6 +325,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -332,6 +341,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -347,6 +357,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -362,6 +373,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -377,6 +389,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -392,6 +405,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -407,6 +421,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -422,6 +437,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -437,6 +453,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -452,6 +469,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -485,6 +503,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -506,6 +525,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -546,6 +566,7 @@ Array [
"Content-Type": "application/json",
},
"method": "GET",
"signal": AbortSignal {},
},
]
`;
2 changes: 2 additions & 0 deletions src/management/__tests__/__snapshots__/users.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Array [
"Content-Type": "application/json",
},
"method": "GET",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -261,6 +262,7 @@ Array [
"Content-Type": "application/json",
},
"method": "PATCH",
"signal": AbortSignal {},
},
]
`;
Expand Down
6 changes: 6 additions & 0 deletions src/networking/__tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Array [
"Content-Type": "application/json",
},
"method": "GET",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -28,6 +29,7 @@ Array [
"Content-Type": "application/json",
},
"method": "GET",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -77,6 +79,7 @@ Array [
"Content-Type": "application/json",
},
"method": "PATCH",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -92,6 +95,7 @@ Array [
"Content-Type": "application/json",
},
"method": "PATCH",
"signal": AbortSignal {},
},
]
`;
Expand Down Expand Up @@ -141,6 +145,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand All @@ -156,6 +161,7 @@ Array [
"Content-Type": "application/json",
},
"method": "POST",
"signal": AbortSignal {},
},
]
`;
Expand Down
Loading

0 comments on commit 6a9d257

Please sign in to comment.