-
Notifications
You must be signed in to change notification settings - Fork 5
/
recorder.config.js
38 lines (31 loc) · 922 Bytes
/
recorder.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = {
ignore(request) {
// Ignore all internal calls
if (request.href.startsWith("http://127.0.0.1/")) {
return true;
}
return false;
},
identify(request, response) {
const { authorization } = request.headers;
const { pathname, query } = request.url;
const { access_token, username } = query;
// Identify any calls with `?access_token=...`
if (access_token) {
return access_token;
}
// Identify any calls with `Authorization: Bearer ...`
if (authorization) {
const [, token] = authorization.split("Bearer ");
return token;
}
if (pathname === "/oauth/token" && username) {
// Identify requests by `/oauth/token?username=...`
if (!response) {
return username;
}
// Associate `{ access_token: ... }` with `?username=...`
return [username, response.body.access_token];
}
}
};