You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
This commit is contained in:
@@ -228,6 +228,34 @@ export default class OneDriveApi {
|
||||
}
|
||||
}
|
||||
|
||||
// Takes an object in the form
|
||||
// { headers: { Authorization: "token here" } }
|
||||
// or
|
||||
// { Authorization: "token here" }
|
||||
// Intended to be used for before logging objects that could potentially have an
|
||||
// Authorization token.
|
||||
public authorizationTokenRemoved(data: any, depth = 0) {
|
||||
const newData: any = {};
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (depth > 5) {
|
||||
return '[[depth-exceeded]]';
|
||||
}
|
||||
|
||||
for (const key in data) {
|
||||
if (key === 'Authorization') {
|
||||
newData[key] = '[[DELETED]]';
|
||||
} else {
|
||||
newData[key] = this.authorizationTokenRemoved(data[key], depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return newData;
|
||||
}
|
||||
|
||||
public async exec(method: string, path: string, query: any = null, data: any = null, options: any = null) {
|
||||
if (!path) throw new Error('Path is required');
|
||||
|
||||
@@ -363,7 +391,13 @@ export default class OneDriveApi {
|
||||
// Deleting a non-existing item is ok - noop
|
||||
return;
|
||||
} else {
|
||||
error.request = `${method} ${url} ${JSON.stringify(query)} ${JSON.stringify(data)} ${JSON.stringify(options)}`;
|
||||
error.request = [
|
||||
method,
|
||||
url,
|
||||
JSON.stringify(query),
|
||||
JSON.stringify(this.authorizationTokenRemoved(data)),
|
||||
JSON.stringify(this.authorizationTokenRemoved(options)),
|
||||
].join(' ');
|
||||
error.headers = await response.headers;
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user