You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-11 23:17:19 +02:00
Compare commits
1 Commits
ios_releas
...
fix_onedri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31396f46ac |
43
ElectronClient/package-lock.json
generated
43
ElectronClient/package-lock.json
generated
@@ -5349,12 +5349,12 @@
|
|||||||
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
||||||
},
|
},
|
||||||
"form-data": {
|
"form-data": {
|
||||||
"version": "2.3.2",
|
"version": "2.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
|
||||||
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
|
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"asynckit": "^0.4.0",
|
"asynckit": "^0.4.0",
|
||||||
"combined-stream": "1.0.6",
|
"combined-stream": "^1.0.6",
|
||||||
"mime-types": "^2.1.12"
|
"mime-types": "^2.1.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -7466,6 +7466,16 @@
|
|||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"form-data": {
|
||||||
|
"version": "2.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
|
||||||
|
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
|
||||||
|
"requires": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.6",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"tough-cookie": {
|
"tough-cookie": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
|
||||||
@@ -8667,6 +8677,19 @@
|
|||||||
"tough-cookie": "~2.5.0",
|
"tough-cookie": "~2.5.0",
|
||||||
"tunnel-agent": "^0.6.0",
|
"tunnel-agent": "^0.6.0",
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"form-data": {
|
||||||
|
"version": "2.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
|
||||||
|
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.6",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
@@ -10268,6 +10291,18 @@
|
|||||||
"tough-cookie": "~2.3.3",
|
"tough-cookie": "~2.3.3",
|
||||||
"tunnel-agent": "^0.6.0",
|
"tunnel-agent": "^0.6.0",
|
||||||
"uuid": "^3.1.0"
|
"uuid": "^3.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"form-data": {
|
||||||
|
"version": "2.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
|
||||||
|
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
|
||||||
|
"requires": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.6",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request-promise-core": {
|
"request-promise-core": {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
"file-uri-to-path": "^1.0.0",
|
"file-uri-to-path": "^1.0.0",
|
||||||
"follow-redirects": "^1.5.0",
|
"follow-redirects": "^1.5.0",
|
||||||
"font-awesome-filetypes": "^2.1.0",
|
"font-awesome-filetypes": "^2.1.0",
|
||||||
"form-data": "^2.3.2",
|
"form-data": "^2.5.1",
|
||||||
"formatcoords": "^1.1.3",
|
"formatcoords": "^1.1.3",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^5.0.0",
|
||||||
"highlight.js": "^10.1.1",
|
"highlight.js": "^10.1.1",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const { stringify } = require('query-string');
|
|||||||
const { time } = require('lib/time-utils.js');
|
const { time } = require('lib/time-utils.js');
|
||||||
const Logger = require('lib/Logger').default;
|
const Logger = require('lib/Logger').default;
|
||||||
const { _ } = require('lib/locale');
|
const { _ } = require('lib/locale');
|
||||||
|
const urlUtils = require('lib/urlUtils.js');
|
||||||
|
|
||||||
class OneDriveApi {
|
class OneDriveApi {
|
||||||
// `isPublic` is to tell OneDrive whether the application is a "public" one (Mobile and desktop
|
// `isPublic` is to tell OneDrive whether the application is a "public" one (Mobile and desktop
|
||||||
@@ -90,16 +91,16 @@ class OneDriveApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execTokenRequest(code, redirectUri) {
|
async execTokenRequest(code, redirectUri) {
|
||||||
const body = new shim.FormData();
|
const body = {};
|
||||||
body.append('client_id', this.clientId());
|
body['client_id'] = this.clientId();
|
||||||
if (!this.isPublic()) body.append('client_secret', this.clientSecret());
|
if (!this.isPublic()) body['client_secret'] = this.clientSecret();
|
||||||
body.append('code', code);
|
body['code'] = code;
|
||||||
body.append('redirect_uri', redirectUri);
|
body['redirect_uri'] = redirectUri;
|
||||||
body.append('grant_type', 'authorization_code');
|
body['grant_type'] = 'authorization_code';
|
||||||
|
|
||||||
const r = await shim.fetch(this.tokenBaseUrl(), {
|
const r = await shim.fetch(this.tokenBaseUrl(), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: body,
|
body: urlUtils.objectToQueryString(body),
|
||||||
headers: {
|
headers: {
|
||||||
['Content-Type']: 'application/x-www-form-urlencoded',
|
['Content-Type']: 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
@@ -366,19 +367,21 @@ class OneDriveApi {
|
|||||||
throw new Error(_('Cannot refresh token: authentication data is missing. Starting the synchronisation again may fix the problem.'));
|
throw new Error(_('Cannot refresh token: authentication data is missing. Starting the synchronisation again may fix the problem.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = new shim.FormData();
|
const body = {};
|
||||||
body.append('client_id', this.clientId());
|
body['client_id'] = this.clientId();
|
||||||
if (!this.isPublic()) body.append('client_secret', this.clientSecret());
|
if (!this.isPublic()) body['client_secret'] = this.clientSecret();
|
||||||
body.append('refresh_token', this.auth_.refresh_token);
|
body['refresh_token'] = this.auth_.refresh_token;
|
||||||
body.append('redirect_uri', 'http://localhost:1917');
|
body['redirect_uri'] = 'http://localhost:1917';
|
||||||
body.append('grant_type', 'refresh_token');
|
body['grant_type'] = 'refresh_token';
|
||||||
|
|
||||||
const options = {
|
const response = await shim.fetch(this.tokenBaseUrl(), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: body,
|
body: urlUtils.objectToQueryString(body),
|
||||||
};
|
headers: {
|
||||||
|
['Content-Type']: 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const response = await shim.fetch(this.tokenBaseUrl(), options);
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
this.setAuth(null);
|
this.setAuth(null);
|
||||||
const msg = await response.text();
|
const msg = await response.text();
|
||||||
|
|||||||
@@ -91,4 +91,18 @@ urlUtils.extractResourceUrls = function(text) {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
urlUtils.objectToQueryString = function(query) {
|
||||||
|
if (!query) return '';
|
||||||
|
|
||||||
|
let queryString = '';
|
||||||
|
const s = [];
|
||||||
|
for (const k in query) {
|
||||||
|
if (!query.hasOwnProperty(k)) continue;
|
||||||
|
s.push(`${encodeURIComponent(k)}=${encodeURIComponent(query[k])}`);
|
||||||
|
}
|
||||||
|
queryString = s.join('&');
|
||||||
|
|
||||||
|
return queryString;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = urlUtils;
|
module.exports = urlUtils;
|
||||||
|
|||||||
Reference in New Issue
Block a user